Lino Website

pDevMode returned by win32print.GetPrinter() is None

Sunday, 4. February 2007 15:29.

Here is a case where the object returned by win32print.GetPrinter() has no pDevMode property. The circumstances are mysterious. I work around this by not setting PaperSize and Orientation in this case (so the printer's defaults are used). Here is a traceback of how it looked before the workaround.

c:\docs\examples\textprinter>lino prnprint 5.prn
Lino prnprint
Homepage: http://lino.saffre-rumma.ee/prnprint.html
Copyright (c) 2004-2006 Luc Saffre.
This software comes with ABSOLUTELY NO WARRANTY and is
distributed under the terms of the GNU General Public License.
See file COPYING.txt for more information.
Using Lino 0.6.27, Python 2.5.0 final, Python Windows Extensions, PIL
Traceback (most recent call last):
  File "", line 1, in 
  File "c:\src\lino\runscript.py", line 81, in 
    m.main()
  File "c:\src\lino\scripts\prnprint.py", line 124, in main
    PrnPrint().main(*args,**kw)
  File "c:\src\lino\console\application.py", line 179, in main
    ret=self.run(*args,**kw)
  File "c:\src\lino\scripts\prnprint.py", line 113, in run
    d.readfile(inputfile)
  File "c:\src\lino\textprinter\textprinter.py", line 225, in readfile
    self.writeln(line)
  File "c:\src\lino\textprinter\textprinter.py", line 283, in writeln
    self.writechars(line)
  File "c:\src\lino\textprinter\textprinter.py", line 297, in writechars
    self.beginDoc()
  File "c:\src\lino\textprinter\textprinter.py", line 184, in beginDoc
    self.onBeginDoc()
  File "c:\src\lino\textprinter\winprn.py", line 223, in onBeginDoc
    devmode.PaperSize = 9 # DMPAPER_A4
AttributeError: 'NoneType' object has no attribute 'PaperSize'

Here is the debug message issued for the above case after the workaround:

{'Status': 0, 'UntilTime': 0, 'pDriverName': 'Samsung ML-1200 Series',
'cJobs': 0, 'pSepFile': '', 'AveragePPM': 0, 'pPortName': 'LPT1:',
'pParameters': '', 'pPrintProcessor': 'WinPrint', 'Attributes': 24,
'Priority': 1, 'pPrinterName': '\\ \\kylliki\\Samsung ML-1200 Series',
'DefaultPriority': 0, 'StartTime': 0, 'pDatatype': 'RAW', 'pDevMode':
None, 'pLocation': '', 'pShareName': 'ML-1200', 'pServerName':
'\\\\kylliki', 'pSecurityDescriptor': , 'pComment': 'Samsung ML-1210/ML-1220M'} has no pDevMode
property

Copyright 2001-2007 Luc Saffre.
http://lino.saffre-rumma.ee
Generated 2007-06-07 16:22:54