summaryrefslogtreecommitdiff
path: root/source3/python/examples/spoolss/enumprinters.py
diff options
context:
space:
mode:
Diffstat (limited to 'source3/python/examples/spoolss/enumprinters.py')
-rwxr-xr-xsource3/python/examples/spoolss/enumprinters.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/source3/python/examples/spoolss/enumprinters.py b/source3/python/examples/spoolss/enumprinters.py
index bf08b95bb9..478c46bc24 100755
--- a/source3/python/examples/spoolss/enumprinters.py
+++ b/source3/python/examples/spoolss/enumprinters.py
@@ -1,20 +1,28 @@
#!/usr/bin/env python
#
-# Display information on all printers on a print server
+# Display information on all printers on a print server. Defaults to
+# printer info level 1.
+#
+# Example: enumprinters.py win2kdc1
#
-import sys, spoolss
+import sys
+from samba import spoolss
-if len(sys.argv) != 2:
- print "Usage: changeid.py <printername>"
+if len(sys.argv) < 2 or len(sys.argv) > 3:
+ print "Usage: enumprinters.py <servername> [infolevel]"
sys.exit(1)
printserver = sys.argv[1]
+level = 1
+if len(sys.argv) == 3:
+ level = int(sys.argv[2])
+
# Get list of printers
try:
- printer_list = spoolss.enumprinters(printserver)
+ printer_list = spoolss.enumprinters("\\\\%s" % printserver)
except:
print "error enumerating printers on %s" % printserver
sys.exit(1)
@@ -22,4 +30,7 @@ except:
# Display basic info
for printer in printer_list:
- print "%s: %s" % (printer["printer_name"], printer["comment"])
+ h = spoolss.openprinter("\\\\%s\\%s" % (printserver, printer))
+ info = h.getprinter(level = level)
+ print "Printer info %d for %s: %s" % (level, printer, info)
+ print