summaryrefslogtreecommitdiffstats
path: root/source3/python/gprinterdata
blob: cd062076c0b49b83d0c05d59df9b23d01beb9a4a (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
35
36
37
38
39
#!/usr/bin/env python

import sys
from gtkdictbrowser import GtkDictBrowser, hex_string
import gtk
from samba import spoolss
import string
import printerdata

# Initialise printerdata dictionary

if len(sys.argv) < 2 or len(sys.argv) > 3:
    print "Usage: gprinterdata [--ex] <printer>"
    print "where <printer> is a UNC printer name."
    sys.exit(1)

try:
    host = string.replace(sys.argv[len(sys.argv) - 1], "/", "\\")
    if sys.argv[1] == "--ex":
        t = printerdata.printerdata_ex(host)
    else:
        t = printerdata.printerdata(host)
except:
    print "gprinterdata: error opening %s" % sys.argv[len(sys.argv) - 1]
    sys.exit(1)

# Create interface

db = GtkDictBrowser(t)
db.register_get_value_text_fn("", hex_string)
db.build_ui('gprinterdata')

# Override Python's handling of ctrl-c so we can break out of the
# gui from the command line.

import signal
signal.signal(signal.SIGINT, signal.SIG_DFL)

gtk.mainloop()