2008-06-18 20:19:40 +00:00
|
|
|
|
|
|
|
from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path
|
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']
|
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:
|
|
|
|
rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
|
|
|
|
if path == '/':
|
|
|
|
path = ''
|
|
|
|
url = nodeurl + "uri/%s" % urllib.quote(rootcap)
|
|
|
|
if path:
|
|
|
|
url += "/" + escape_path(path)
|
|
|
|
else:
|
|
|
|
url = nodeurl
|
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
|
|
|
|
|