Possible to set printer devmode using samba3-python?

daniel.jarboe at custserv.com daniel.jarboe at custserv.com
Wed Nov 12 14:50:54 GMT 2003


> A valid *devmode* can only be set (if it needs to be set) by 
> *executing*
> the Windows binaries of the Windows printer driver. That execution is
> only possible by opening the driver properties from a Windows client,
> thusly causing a client-side driver execution.
> 
> It suffices to change (f.e.) the page mode from "portrait" to 
> "landscape",
> then "Apply", then back again to have that Windows code executed once
> (on the Windows client), and then loaded back a valid device mode onto
> the (Samba) server.
> 
> But maybe I don't understand your intention?

My intention is to copy all printer-related settings from an NT
print-server to a samba server.  The NT server is already configured
appropriately with several printers, and if I can clone those settings,
it would be a big time-saver and less error prone.  Also, for new
printers to be installed, I'd like our print admin to have the
capability of installing/configuring/shareing the printer on a windows
pc like they've always done, then trigger a process on our samba server
to use smbclient to retrieve the drivers from their PC, rpcclient
adddriver the printer to samba, and then copy all the printer settings /
devmode etc.  It's this copy all the printer settings / devmode etc
portion that is tripping me up.

Our users require functionality available in vendor-provided print
drivers that don't take kindly to being remotely uploaded to a samba
server using print$, and I'm hoping that I can get them to work by
installing them locally and then duplicating all the driver files /
settings they use onto the samba server.

> What is the "samba3-python" thing you are talking about?

Experimental python helpers that can be built with samba 3.  It allows
an interface to many of the spoolss commands from python scripts.  I
thought I might be able to take advantage of this interface to achieve
the printer share cloning.

> Maybe you are intending to address the setting of 
> user-selectable printjob
> options to certain defaults (and not setting a "DeviceMode" 
> which is s.th.
> different...)?

Yes, that too.  Everything.  I'm not sure what data is stored where when
it comes to the various Window printing driver options, but by copying
all of it I should be covered.

> > I'm trying to automate printer driver installation on samba 
> servers for
> > Our print admin.  I've no problem getting the driver files from a
> > windows
> > printer shared with rpcclient and smbclient, and access 
> printerdata to
> > set things like installed printer accessories...
> > 
> 
> But you're doing that from the Windows client? Or?

In effect a process on the samba server becomes a client, connecting to
a windows printer share and copying driver files, printer settings,
devmode, whatever it needs.  Then the process connects to localhost (or
wherever the samba server is) and uploads the printer drivers, and
stores the printer settings (that were originally generated by a windows
client) onto the samba server.

> > But in order to have the printing preferences and defaults 
> set I believe
> > I need getprinter and setprinter.
> > 
> > Getprinter seems to work well, but when doing a python spoolss
> > setprinter for info2, I get:
> > spoolss.werror: [31, 'DOS code 0x0000001f'] ...
> > 
> > And when doing a setprinter(info1) I get segmentation fault.
> > backtrace of core yields:
> > #0  0x40322688 in prs_uint32 ()
> >    from /usr/lib/python2.2/lib-dynload/samba/spoolss.so
> > #1  0x40372806 in spool_io_printer_info_level_1 ()
> >    from /usr/lib/python2.2/lib-dynload/samba/spoolss.so
> > #2  0x403732a0 in spool_io_printer_info_level ()
> >    from /usr/lib/python2.2/lib-dynload/samba/spoolss.so
> > #3  0x4037129e in spoolss_io_q_setprinter ()
> >    from /usr/lib/python2.2/lib-dynload/samba/spoolss.so
> > #4  0x4038c43e in cli_spoolss_setprinter ()
> >    from /usr/lib/python2.2/lib-dynload/samba/spoolss.so
> > #5  0x402bcbd4 in spoolss_hnd_setprinter ()
> >    from /usr/lib/python2.2/lib-dynload/samba/spoolss.so
> > #6  0x00490162 in PyCFunction_Call ()
> > #7  0x0046fe68 in PyObject_Call ()
> > #8  0x00439b7a in PyEval_GetFuncDesc ()
> > 
> > For setprinter(info3) I get:
> > spoolss.error: error converting to printer info 3 ... 
> > That is with info3=hnd.getprinter(level=3) ... I made no 
> modifications
> > to
> > the format of the data.
> > 
> > Is samba3 python not ready for what I'm trying to do?  Any 
> ideas how I
> > can accomplish it by other means? 
> 
> Please explain, in simple words, to a dumb little documentation writer
> what exactly you want to achieve.

Sorry to frustrate you, I know you know your stuff when it comes to
samba and cups printing... you wrote the book on it :).  You know that
there are certain pitfalls necessary to avoid when configuring a samba
printer share to support point 'n print.  All in all, I think it can be
a fairly delicate process, and I'd like to try to eliminate the source
of some potential mistakes... i.e. let our print admin install/configure
a printer share just like they are used to on a windows box, click a
button on a webpage and *poof*, have an exact copy of that printer share
they created on the windows box, available on the samba server.

> 
> > This is with 3.0.1pre2 on SLES8 s/390,
> > with a w2k pc on the other end.
> > 
> > Thanks,
> > ~ Daniel
> 
> 
> 

-----------------------------------------------------------------------

This message is the property of Time Inc. or its affiliates. It may be
legally privileged and/or confidential and is intended only for the use
of the addressee(s). No addressee should forward, print, copy, or
otherwise reproduce this message in any manner that would allow it to be
viewed by any individual not originally listed as a recipient. If the
reader of this message is not the intended recipient, you are hereby
notified that any unauthorized disclosure, dissemination, distribution,
copying or the taking of any action in reliance on the information
herein is strictly prohibited. If you have received this communication
in error, please immediately notify the sender and delete this message.
Thank you.




More information about the samba-technical mailing list