From: Brian Warner Date: Wed, 1 Jul 2009 20:05:48 +0000 (-0700) Subject: cli: webopen: when called with no arguments, open the Welcome page X-Git-Tag: trac-4000~45 X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/readonly?a=commitdiff_plain;h=b640baf50009c795988143fd6a868255d121bc20;p=tahoe-lafs%2Ftahoe-lafs.git cli: webopen: when called with no arguments, open the Welcome page --- diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index 56365fb6..69d96c8d 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -300,7 +300,7 @@ class WebopenOptions(VDriveOptions): def getSynopsis(self): return "%s webopen [ALIAS:PATH]" % (os.path.basename(sys.argv[0]),) - longdesc = """Opens a webbrowser to the contents of some portion of the virtual drive.""" + longdesc = """Opens a webbrowser to the contents of some portion of the virtual drive. When called without arguments, opens to the Welcome page.""" class ManifestOptions(VDriveOptions): optFlags = [ diff --git a/src/allmydata/scripts/tahoe_webopen.py b/src/allmydata/scripts/tahoe_webopen.py index 6470bb40..b4e13c14 100644 --- a/src/allmydata/scripts/tahoe_webopen.py +++ b/src/allmydata/scripts/tahoe_webopen.py @@ -7,12 +7,15 @@ def webopen(options, opener=None): if not nodeurl.endswith("/"): nodeurl += "/" where = options.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) + 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 if not opener: import webbrowser opener = webbrowser.open diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index f990ebb3..8b46502d 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -474,6 +474,7 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase): aliases = get_aliases(self.get_clientdir()) node_url_file = os.path.join(self.get_clientdir(), "node.url") nodeurl = open(node_url_file, "r").read().strip() + self.welcome_url = nodeurl uribase = nodeurl + "uri/" self.tahoe_url = uribase + urllib.quote(aliases["tahoe"]) self.tahoe_subdir_url = self.tahoe_url + "/subdir" @@ -505,7 +506,7 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase): d.addCallback(_check_add_duplicate) def _test_urls(junk): - self._test_webopen([], self.tahoe_url) + self._test_webopen([], self.welcome_url) self._test_webopen(["/"], self.tahoe_url) self._test_webopen(["tahoe:"], self.tahoe_url) self._test_webopen(["tahoe:/"], self.tahoe_url)