1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-14 19:24:43 +03:00

A printerdata browser I whipped up in about 5 minutes. (-:

Usage: gprinterdata //win2kdc1/fooprinter
(This used to be commit a3e52367c961070ce80ac3d4bba763ad9ec1007c)
This commit is contained in:
Tim Potter 2002-09-03 01:48:24 +00:00
parent 8e56ded996
commit 53495225a5

44
source3/python/gprinterdata Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env python
import sys
from gtkdictbrowser import GtkDictBrowser
import gtk
import spoolss
import string
class printerdata:
def __init__(self, host):
host = string.replace(host, "/", "\\")
self.hnd = spoolss.openprinter(host)
def keys(self):
return self.hnd.enumprinterdata().keys()
def __getitem__(self, key):
return self.hnd.getprinterdata(key)['data']
# Initialise printerdata dictionary
if len(sys.argv) != 2:
print "Usage: gprinterdata <printer>"
print "where <printer> is a UNC printer name."
sys.exit(1)
try:
t = printerdata(sys.argv[1])
except:
print "gprinterdata: error opening %s" % sys.argv[1]
sys.exit(1)
# Create interface
db = GtkDictBrowser(t)
db.build_ui('gprinterdata')
# Override Python's handling of ctrl-c so we can break out of the
# gui from the command line.
import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)
gtk.mainloop()