| Line | |
|---|
| 1 | #!/usr/bin/python
|
|---|
| 2 | #
|
|---|
| 3 | # Display the changeid for a list of printers given on the command line
|
|---|
| 4 | #
|
|---|
| 5 | # Sample usage:
|
|---|
| 6 | #
|
|---|
| 7 | # changeid.py '\\win2kdc1\magpie'
|
|---|
| 8 | #
|
|---|
| 9 |
|
|---|
| 10 | import sys
|
|---|
| 11 | from samba import spoolss
|
|---|
| 12 |
|
|---|
| 13 | if len(sys.argv) == 1:
|
|---|
| 14 | print "Usage: changeid.py <printername>"
|
|---|
| 15 | sys.exit(1)
|
|---|
| 16 |
|
|---|
| 17 | for printer in sys.argv[1:]:
|
|---|
| 18 |
|
|---|
| 19 | # Open printer handle
|
|---|
| 20 |
|
|---|
| 21 | try:
|
|---|
| 22 | hnd = spoolss.openprinter(printer)
|
|---|
| 23 | except:
|
|---|
| 24 | print "error opening printer %s" % printer
|
|---|
| 25 | sys.exit(1)
|
|---|
| 26 |
|
|---|
| 27 | # Fetch and display changeid
|
|---|
| 28 |
|
|---|
| 29 | info = hnd.getprinter(level = 0)
|
|---|
| 30 | print info["change_id"]
|
|---|
| 31 |
|
|---|
| 32 | # Clean up
|
|---|
| 33 |
|
|---|
| 34 | spoolss.closeprinter(hnd)
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.