summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-07-26 01:01:27 +0000
committerTim Potter <tpot@samba.org>2002-07-26 01:01:27 +0000
commit0c8e0571b77d6bee1a0d78f5f100ce03e8f04697 (patch)
tree552ff96d31b610ecffe99c24597c3fe09c0f8d42 /source3
parent45e71ce21bcebe67f8464ce7d8531f0ebaa4b457 (diff)
downloadsamba-0c8e0571b77d6bee1a0d78f5f100ce03e8f04697.tar.gz
samba-0c8e0571b77d6bee1a0d78f5f100ce03e8f04697.tar.bz2
samba-0c8e0571b77d6bee1a0d78f5f100ce03e8f04697.zip
Print out a friendly message on error instead of a python exception when
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)
Diffstat (limited to 'source3')
-rwxr-xr-xsource3/python/gtdbtool12
1 files changed, 11 insertions, 1 deletions
diff --git a/source3/python/gtdbtool b/source3/python/gtdbtool
index 6513366790..792cdeecc0 100755
--- a/source3/python/gtdbtool
+++ b/source3/python/gtdbtool
@@ -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()