]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blobdiff - src/allmydata/scripts/tahoe_webopen.py
Alter CLI utilities to handle nonexistent aliases better
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / scripts / tahoe_webopen.py
index b4e13c1482a89e3f713f21f7cbd780b1a183ea39..37d157b08deb04ba00c8f9e222c58749f10b165f 100644 (file)
@@ -1,14 +1,20 @@
 
-from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path
+from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \
+                                     UnknownAliasError
 import urllib
 
 def webopen(options, opener=None):
     nodeurl = options['node-url']
+    stderr = options.stderr
     if not nodeurl.endswith("/"):
         nodeurl += "/"
     where = options.where
     if where:
-        rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
+        try:
+            rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
+        except UnknownAliasError, e:
+            print >>stderr, "error: %s" % e.args[0]
+            return 1
         if path == '/':
             path = ''
         url = nodeurl + "uri/%s" % urllib.quote(rootcap)