Merge a trivial fix across from HEAD. Not that this
[Samba.git] / source / python / gtdbtool
blob129f4fe0e2e6377bd486a3f2b4b3a5dd5a3e5762
1 #!/usr/bin/env python
3 import sys
4 from gtkdictbrowser import GtkDictBrowser
5 import gtk
6 from samba import tdb
7 import string
9 # Open handle on tdb
11 if len(sys.argv) != 2:
12 print "Usage: gdbtool <tdbfile>"
13 sys.exit(1)
15 try:
16 t = tdb.open(sys.argv[1])
17 except tdb.error, t:
18 print "gtdbtool: error opening %s: %s" % (sys.argv[1], t)
19 sys.exit(1)
21 # Create interface
23 db = GtkDictBrowser(t)
25 def display_key_x00(key):
26 """Remove \x00 from all keys as they mucks up GTK."""
27 return string.replace(key, "\x00", "")
29 db.register_get_key_text_fn(display_key_x00)
31 db.build_ui('gtdbtool')
33 # Override Python's handling of ctrl-c so we can break out of the
34 # gui from the command line.
36 import signal
37 signal.signal(signal.SIGINT, signal.SIG_DFL)
39 gtk.mainloop()