]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - src/allmydata/scripts/tahoe_webopen.py
cli: webopen: when called with no arguments, open the Welcome page
[tahoe-lafs/tahoe-lafs.git] / src / allmydata / scripts / tahoe_webopen.py
1
2 from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path
3 import urllib
4
5 def webopen(options, opener=None):
6     nodeurl = options['node-url']
7     if not nodeurl.endswith("/"):
8         nodeurl += "/"
9     where = options.where
10     if where:
11         rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
12         if path == '/':
13             path = ''
14         url = nodeurl + "uri/%s" % urllib.quote(rootcap)
15         if path:
16             url += "/" + escape_path(path)
17     else:
18         url = nodeurl
19     if not opener:
20         import webbrowser
21         opener = webbrowser.open
22     opener(url)
23     return 0
24