summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-09-19 00:14:01 +0000
committerTim Potter <tpot@samba.org>2002-09-19 00:14:01 +0000
commit15fdb18dd7f7169be9f22b639a6e1e9bcab833b9 (patch)
tree2d3678c6482c21fac8a184941dd2493d85245538 /source3
parent7af9901fdb56ddf02c821064ccaeece7661c3b97 (diff)
downloadsamba-15fdb18dd7f7169be9f22b639a6e1e9bcab833b9.tar.gz
samba-15fdb18dd7f7169be9f22b639a6e1e9bcab833b9.tar.bz2
samba-15fdb18dd7f7169be9f22b639a6e1e9bcab833b9.zip
Implement printerdata_ex as Python dictionary. Read only at the moment.
(This used to be commit 739ea89eb3ab49e5dccddfa767812811b413e67d)
Diffstat (limited to 'source3')
-rw-r--r--source3/python/printerdata.py43
-rw-r--r--source3/python/samba/printerdata.py43
2 files changed, 64 insertions, 22 deletions
diff --git a/source3/python/printerdata.py b/source3/python/printerdata.py
index 3384de4f30..33251f6a00 100644
--- a/source3/python/printerdata.py
+++ b/source3/python/printerdata.py
@@ -1,10 +1,18 @@
+#!/usr/bin/env python
+
#
# A python module that maps printerdata to a dictionary. We define
# two classes. The printerdata class maps to Get/Set/Enum/DeletePrinterData
# and the printerdata_ex class maps to Get/Set/Enum/DeletePrinterDataEx
#
-import spoolss
+#
+# TODO:
+#
+# - Implement __delitem__
+#
+
+from samba import spoolss
class printerdata:
def __init__(self, host, creds = {}):
@@ -22,17 +30,30 @@ class printerdata:
"data": value})
class printerdata_ex:
- def __init__(self, host, creds = {}):
- self.hnd = spoolss.openprinter(host, creds = creds)
+ def __init__(self, host):
+ self.host = host
+ self.top_level_keys = ["PrinterDriverData", "DsSpooler", "DsDriver",
+ "DsUser"]
def keys(self):
- return self.hnd.enumprinterdataex("PrinterDriverData").keys()
+ return self.top_level_keys
- def __getitem__(self, key):
- return self.hnd.getprinterdataex("PrinterDriverData", key)['data']
+ def has_key(self, key):
+ for k in self.top_level_keys:
+ if k == key:
+ return 1
+ return 0
- def __setitem__(self, key, value):
- # Store as REG_BINARY for now
- self.hnd.setprinterdataex({"key": "PrinterDriverData", "value": key, "type": 3,
- "data": value})
-
+ class printerdata_ex_subkey:
+ def __init__(self, host, key):
+ self.hnd = spoolss.openprinter(host)
+ self.key = key
+
+ def keys(self):
+ return self.hnd.enumprinterdataex(self.key).keys()
+
+ def __getitem__(self, key):
+ return self.hnd.getprinterdataex(self.key, key)['data']
+
+ def __getitem__(self, key):
+ return self.printerdata_ex_subkey(self.host, key)
diff --git a/source3/python/samba/printerdata.py b/source3/python/samba/printerdata.py
index 3384de4f30..33251f6a00 100644
--- a/source3/python/samba/printerdata.py
+++ b/source3/python/samba/printerdata.py
@@ -1,10 +1,18 @@
+#!/usr/bin/env python
+
#
# A python module that maps printerdata to a dictionary. We define
# two classes. The printerdata class maps to Get/Set/Enum/DeletePrinterData
# and the printerdata_ex class maps to Get/Set/Enum/DeletePrinterDataEx
#
-import spoolss
+#
+# TODO:
+#
+# - Implement __delitem__
+#
+
+from samba import spoolss
class printerdata:
def __init__(self, host, creds = {}):
@@ -22,17 +30,30 @@ class printerdata:
"data": value})
class printerdata_ex:
- def __init__(self, host, creds = {}):
- self.hnd = spoolss.openprinter(host, creds = creds)
+ def __init__(self, host):
+ self.host = host
+ self.top_level_keys = ["PrinterDriverData", "DsSpooler", "DsDriver",
+ "DsUser"]
def keys(self):
- return self.hnd.enumprinterdataex("PrinterDriverData").keys()
+ return self.top_level_keys
- def __getitem__(self, key):
- return self.hnd.getprinterdataex("PrinterDriverData", key)['data']
+ def has_key(self, key):
+ for k in self.top_level_keys:
+ if k == key:
+ return 1
+ return 0
- def __setitem__(self, key, value):
- # Store as REG_BINARY for now
- self.hnd.setprinterdataex({"key": "PrinterDriverData", "value": key, "type": 3,
- "data": value})
-
+ class printerdata_ex_subkey:
+ def __init__(self, host, key):
+ self.hnd = spoolss.openprinter(host)
+ self.key = key
+
+ def keys(self):
+ return self.hnd.enumprinterdataex(self.key).keys()
+
+ def __getitem__(self, key):
+ return self.hnd.getprinterdataex(self.key, key)['data']
+
+ def __getitem__(self, key):
+ return self.printerdata_ex_subkey(self.host, key)