summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsource3/python/gprinterdata13
-rw-r--r--source3/python/printerdata.py15
-rw-r--r--source3/python/samba/printerdata.py15
3 files changed, 38 insertions, 5 deletions
diff --git a/source3/python/gprinterdata b/source3/python/gprinterdata
index f1992db5a56..59c5f3c3151 100755
--- a/source3/python/gprinterdata
+++ b/source3/python/gprinterdata
@@ -9,16 +9,19 @@ import printerdata
# Initialise printerdata dictionary
-if len(sys.argv) != 2:
- print "Usage: gprinterdata <printer>"
+if len(sys.argv) < 2 or len(sys.argv) > 3:
+ print "Usage: gprinterdata [--ex] <printer>"
print "where <printer> is a UNC printer name."
sys.exit(1)
try:
- host = string.replace(sys.argv[1], "/", "\\")
- t = printerdata.printerdata(host)
+ host = string.replace(sys.argv[len(sys.argv) - 1], "/", "\\")
+ if sys.argv[1] == "--ex":
+ t = printerdata.printerdata_ex(host)
+ else:
+ t = printerdata.printerdata(host)
except:
- print "gprinterdata: error opening %s" % sys.argv[1]
+ print "gprinterdata: error opening %s" % sys.argv[len(sys.argv) - 1]
sys.exit(1)
# Create interface
diff --git a/source3/python/printerdata.py b/source3/python/printerdata.py
index 55b5fdf6ae7..3384de4f30b 100644
--- a/source3/python/printerdata.py
+++ b/source3/python/printerdata.py
@@ -21,3 +21,18 @@ class printerdata:
self.hnd.setprinterdata({"key": "", "value": key, "type": 3,
"data": value})
+class printerdata_ex:
+ def __init__(self, host, creds = {}):
+ self.hnd = spoolss.openprinter(host, creds = creds)
+
+ def keys(self):
+ return self.hnd.enumprinterdataex("PrinterDriverData").keys()
+
+ def __getitem__(self, key):
+ return self.hnd.getprinterdataex("PrinterDriverData", key)['data']
+
+ def __setitem__(self, key, value):
+ # Store as REG_BINARY for now
+ self.hnd.setprinterdataex({"key": "PrinterDriverData", "value": key, "type": 3,
+ "data": value})
+
diff --git a/source3/python/samba/printerdata.py b/source3/python/samba/printerdata.py
index 55b5fdf6ae7..3384de4f30b 100644
--- a/source3/python/samba/printerdata.py
+++ b/source3/python/samba/printerdata.py
@@ -21,3 +21,18 @@ class printerdata:
self.hnd.setprinterdata({"key": "", "value": key, "type": 3,
"data": value})
+class printerdata_ex:
+ def __init__(self, host, creds = {}):
+ self.hnd = spoolss.openprinter(host, creds = creds)
+
+ def keys(self):
+ return self.hnd.enumprinterdataex("PrinterDriverData").keys()
+
+ def __getitem__(self, key):
+ return self.hnd.getprinterdataex("PrinterDriverData", key)['data']
+
+ def __setitem__(self, key, value):
+ # Store as REG_BINARY for now
+ self.hnd.setprinterdataex({"key": "PrinterDriverData", "value": key, "type": 3,
+ "data": value})
+