summaryrefslogtreecommitdiffstats
path: root/source/python/gprinterdata
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-09-03 01:48:24 +0000
committerTim Potter <tpot@samba.org>2002-09-03 01:48:24 +0000
commita3e52367c961070ce80ac3d4bba763ad9ec1007c (patch)
tree4def22e3600f6088475c528d7f9d5cce3606fbdd /source/python/gprinterdata
parent6f78c4181449a995b9d5b2955981a20e4fdcc829 (diff)
downloadsamba-a3e52367c961070ce80ac3d4bba763ad9ec1007c.tar.gz
samba-a3e52367c961070ce80ac3d4bba763ad9ec1007c.tar.xz
samba-a3e52367c961070ce80ac3d4bba763ad9ec1007c.zip
A printerdata browser I whipped up in about 5 minutes. (-:
Usage: gprinterdata //win2kdc1/fooprinter
Diffstat (limited to 'source/python/gprinterdata')
-rwxr-xr-xsource/python/gprinterdata44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/python/gprinterdata b/source/python/gprinterdata
new file mode 100755
index 00000000000..cd04e6f5a13
--- /dev/null
+++ b/source/python/gprinterdata
@@ -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()