Archive for June, 2007

Coding standards

Saturday, June 16th, 2007

Reminder to self:

* Follow PEP 8, verify with pep8.py
* Follow PEP 257 for docstrings
* No tabs. Not anywhere. Always indent with 4 spaces.
* Wrap at Line 109
* Use pylint aim for a score of at least 8.
* Write doctests where possible. Always write unittests. Aim for a test coverage of at least 80%
* Classes/Variables which reference Objects specific to our ERP/our Industry/german trade should be in german as technical terms. Generic Objects should be named in english: Lieferscheinnummer, Kundenauftragsnumer, Rechnung but TransportEndpoint and DataStore. This line is very blurry. Comments in the code should be in english.
* Code should be targeted at Python 2.5 on FreeBSD/Linux

~/.pylintrc:

[FORMAT]
max-line-length=110

Python Unicode enabeling

Friday, June 15th, 2007

Unicode still has a LOT of issues. If you have an UFT-8 based system (like a Mac) you can shrink the pain a lot by setting the default encoding to UTF-8. Locate the Python configuration file (e.g. /opt/local/lib/python2.5/site.py) and locate this code:

def setencoding():
    """Set the string encoding used by the Unicode implementation.  The
    default is 'ascii', but if you're willing to experiment, you can
    change this."""
    encoding = "ascii" # Default value set by _PyUnicode_Init()
    if 0:
        [...]

Change encoding = "ascii" to encoding = "utf-8" and you are done.

AS/400 ODBC Troubleshooting Links

Sunday, June 10th, 2007

Troubleshoot ODBC

iSeries Access for Linux ODBC FAQs

SQLSTATE Constants

Where can I look up SQLCOD and SQLSTATE values?

Listing of SQLSTATE class codes

Admin Alert: Turning Off ODBC Query Timeout Limits

ODBC Status Return Codes

Die Störungsstelle hat ne Störung

Sunday, June 10th, 2007

Sunday, June 10th, 2007

Printing form an AS/400

Thursday, June 7th, 2007

The iSeries/AS400 is a very special beast. And printing on it es even more special. The god-given way to print is by specialized printers over specialized cabeling. Everything else is difficult. For example the iSeries can’t output PostScript without serious effort.

Then again, everything is beautifuly documented. Just check IBM AS/400 Printing IV, IBM AS/400 Printing V, IBM eServer iSeries Printing VI: Delivering the Output of e-business and IBM eServer iSeries Printing VII: Infoprint Server Implementation (each arround 400 pages) to get an general overview.

After I did the reading and some additional reading to understand the terminology I found an easy way to print to cups. Having an existing AS/400 print queue “Zuse”, an cups-Server on IP 1.2.3.4 and an CUPS queu named ‘DruckerZuse’ just do that:

ENDWTR ZUSE *IMMED
VRYCFG CFGOBJ(ZUSE) CFGTYPE(*DEV) STATUS(*OFF)
CHGDEVPRT DEVD(ZUSE) PORT(631) MFRTYPMDL(*HP4) RMTLOCNAME(’http://1.2.3.4:631/printers/DruckerZuse’) SYSDRVPGM(*IBMIPPDRV)
VRYCFG CFGOBJ(ZUSE) CFGTYPE(*DEV) STATUS(*ON)
STRPRTWTR DEV(ZUSE)

Now you get a PCL stream on your CUPS server. Converting that to PostScript is described here.

Thursday, June 7th, 2007

GhostPCL

Sunday, June 3rd, 2007

GhostPCL is a tool to convert PCL as generated by LaserJet printer drivers to PostScript. This allows some extremly ugly printing infrastructure based hacks, since there are about 100.000.000 tools available to further process PostScript (or PDF). To get it to compile on FreeBSD 6.x you need this patch and gmake installed.

“Nobody has touched that code in 6 years”

Sunday, June 3rd, 2007

Reading his comment I start wondering again about the thought that Sourceforge is world’s “biggest repository of non-working code”.