summaryrefslogtreecommitdiff
path: root/source3/python/examples/spoolss/changeid.py
blob: 85fe0efe8a4c534e29816d19a4f2511a680c8dde (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
30
31
32
33
34
#!/usr/bin/python
#
# Display the changeid for a list of printers given on the command line
#
# Sample usage:
#
#     changeid.py '\\win2kdc1\magpie'
#

import sys
from samba import 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)