]> git.michaelhowe.org Git - packages/b/bup.git/commitdiff
cmd/web: add an import guard like the one in cmd/fuse
authorRobert S. Edmonds <edmonds@debian.org>
Sat, 10 Aug 2013 19:59:37 +0000 (15:59 -0400)
committerRobert S. Edmonds <edmonds@debian.org>
Sat, 10 Aug 2013 19:59:37 +0000 (15:59 -0400)
In Debian, we replace the embedded copy of tornado with a Recommends on
the python-tornado package. Print a nice error message instead of a
backtrace if the user doesn't have it installed.

Signed-off-by: Robert S. Edmonds <edmonds@debian.org>
cmd/web-cmd.py

index 6e368a28c6886d48b00811e7b5ccafb431a6b193..6a08fa32db23100152a443c681a17f9c5c00f2c6 100755 (executable)
@@ -1,10 +1,15 @@
 #!/usr/bin/env python
 import sys, stat, urllib, mimetypes, posixpath, time
-import tornado.httpserver
-import tornado.ioloop
-import tornado.web
 from bup import options, git, vfs
 from bup.helpers import *
+try:
+    import tornado.httpserver
+    import tornado.ioloop
+    import tornado.web
+except ImportError:
+    log('bup: error: The python "tornado" module is missing.\n' +
+        'Please install it in order to use bup web.\n')
+    sys.exit(1)
 
 handle_ctrl_c()