]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - src/allmydata/scripts/tahoe_webopen.py
92a3023c8748ab408220917935ec4fdf43400ccc
[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
4 def webopen(nodeurl, aliases, where, stdout, stderr):
5     import urllib, webbrowser
6     if not nodeurl.endswith("/"):
7         nodeurl += "/"
8     if where.endswith("/"):
9         where = where[:-1]
10     rootcap, path = get_alias(aliases, where, DEFAULT_ALIAS)
11     url = nodeurl + "uri/%s" % urllib.quote(rootcap)
12     if path:
13         # move where.endswith check here?
14         url += "/" + escape_path(path)
15     webbrowser.open(url)
16     return 0
17