summaryrefslogtreecommitdiffstats
path: root/source3/python/examples/spoolss/changeid.py
blob: b2345094edcbdaa147a960a3362c3570a8b92ce2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/python
#
# Display the changeid for a list of printers given on the command line
#

import sys, spoolss

if len(sys.argv) == 1:
    print "Usage: changeid.py <printername>"
    sys.exit(1)

for printer in sys.argv[1:]:

    # Open printer handle

    try:
        hnd = spoolss.openprinter(printer)
    except:
        print "error opening printer %s" % printer
        sys.exit(1)

    # Fetch and display changeid

    info = hnd.getprinter(level = 0)
    print info["change_id"]

    # Clean up

    spoolss.closeprinter(hnd)