Print out a friendly message on error instead of a python exception when
authorTim Potter <tpot@samba.org>
Fri, 26 Jul 2002 01:01:27 +0000 (01:01 +0000)
committerTim Potter <tpot@samba.org>
Fri, 26 Jul 2002 01:01:27 +0000 (01:01 +0000)
calling tdb.open()

Override Python's SIGINT handler so we can quit from the command line
by hitting Ctrl-C.
(This used to be commit 2adcd0eb4362a20824d1f34b63c0f405a7803872)

source3/python/gtdbtool

index 651336679093eef46986c0bad3322340c550c5ab..792cdeecc0b1080ab272b99b79de7acc4fbe3592 100755 (executable)
@@ -244,7 +244,11 @@ if len(sys.argv) != 2:
     print "Usage: gdbtool <tdbfile>"
     sys.exit(1)
 
-t = tdb.open(sys.argv[1])
+try:
+    t = tdb.open(sys.argv[1])
+except tdb.error, t:
+    print "gtdbtool: error opening %s: %s" % (sys.argv[1], t)
+    sys.exit(1)
 
 # Create user interface
 
@@ -269,4 +273,10 @@ w.register_display_value_fn("PRINTERS/", convert_to_hex)
 
 w.build_ui("gtdbtool: %s" % sys.argv[1])
 
+# 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)
+
 mainloop()