mirror of
https://github.com/samba-team/samba.git
synced 2025-01-14 19:24:43 +03:00
Move printerdata dictionary object into it's own file.
(This used to be commit c211d2deca1019d3ef9bd08f5a01e76ede2d0191)
This commit is contained in:
parent
e411dc9687
commit
a2327b8485
@ -5,18 +5,8 @@ from gtkdictbrowser import GtkDictBrowser, hex_string
|
||||
import gtk
|
||||
import spoolss
|
||||
import string
|
||||
import printerdata
|
||||
|
||||
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:
|
||||
@ -25,7 +15,8 @@ if len(sys.argv) != 2:
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
t = printerdata(sys.argv[1])
|
||||
host = string.replace(sys.argv[1], "/", "\\")
|
||||
t = printerdata.printerdata(host)
|
||||
except:
|
||||
print "gprinterdata: error opening %s" % sys.argv[1]
|
||||
sys.exit(1)
|
||||
|
23
source3/python/printerdata.py
Normal file
23
source3/python/printerdata.py
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
class printerdata:
|
||||
def __init__(self, host, creds = {}):
|
||||
self.hnd = spoolss.openprinter(host, creds = creds)
|
||||
|
||||
def keys(self):
|
||||
return self.hnd.enumprinterdata().keys()
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.hnd.getprinterdata(key)['data']
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
# Store as REG_BINARY for now
|
||||
self.hnd.setprinterdata({"key": "", "value": key, "type": 3,
|
||||
"data": value})
|
||||
|
23
source3/python/samba/printerdata.py
Normal file
23
source3/python/samba/printerdata.py
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# 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
|
||||
|
||||
class printerdata:
|
||||
def __init__(self, host, creds = {}):
|
||||
self.hnd = spoolss.openprinter(host, creds = creds)
|
||||
|
||||
def keys(self):
|
||||
return self.hnd.enumprinterdata().keys()
|
||||
|
||||
def __getitem__(self, key):
|
||||
return self.hnd.getprinterdata(key)['data']
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
# Store as REG_BINARY for now
|
||||
self.hnd.setprinterdata({"key": "", "value": key, "type": 3,
|
||||
"data": value})
|
||||
|
Loading…
x
Reference in New Issue
Block a user