]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - src/allmydata/scripts/tahoe_webopen.py
CLI: reconcile webopen changes
[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 is None:
11         where = 'tahoe:'
12     rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
13     url = nodeurl + "uri/%s" % urllib.quote(rootcap)
14     if path:
15         url += "/" + escape_path(path)
16     if not opener:
17         import webbrowser
18         opener = webbrowser.open
19     opener(url)
20     return 0
21