2008-06-18 20:19:40 +00:00
|
|
|
|
2010-02-11 02:43:18 +00:00
|
|
|
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path, \
|
|
|
|
UnknownAliasError
|
2008-09-24 15:20:02 +00:00
|
|
|
import urllib
|
2008-06-18 20:19:40 +00:00
|
|
|
|
2008-09-24 15:20:02 +00:00
|
|
|
def webopen(options, opener=None):
|
|
|
|
nodeurl = options['node-url']
|
2010-02-11 02:43:18 +00:00
|
|
|
stderr = options.stderr
|
2008-06-18 20:19:40 +00:00
|
|
|
if not nodeurl.endswith("/"):
|
|
|
|
nodeurl += "/"
|
2008-09-24 15:20:02 +00:00
|
|
|
where = options.where
|
2009-07-01 20:05:48 +00:00
|
|
|
if where:
|
2010-02-11 02:43:18 +00:00
|
|
|
try:
|
|
|
|
rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
|
2019-03-28 11:45:28 +00:00
|
|
|
except UnknownAliasError as e:
|
2010-06-07 01:02:15 +00:00
|
|
|
e.display(stderr)
|
2010-02-11 02:43:18 +00:00
|
|
|
return 1
|
2009-07-01 20:05:48 +00:00
|
|
|
if path == '/':
|
|
|
|
path = ''
|
|
|
|
url = nodeurl + "uri/%s" % urllib.quote(rootcap)
|
|
|
|
if path:
|
|
|
|
url += "/" + escape_path(path)
|
|
|
|
else:
|
|
|
|
url = nodeurl
|
2010-04-24 23:30:03 +00:00
|
|
|
if options['info']:
|
|
|
|
url += "?t=info"
|
2008-09-24 15:20:02 +00:00
|
|
|
if not opener:
|
|
|
|
import webbrowser
|
|
|
|
opener = webbrowser.open
|
|
|
|
opener(url)
|
2008-06-18 20:19:40 +00:00
|
|
|
return 0
|
|
|
|
|