From b640baf50009c795988143fd6a868255d121bc20 Mon Sep 17 00:00:00 2001 From: Brian Warner <warner@lothar.com> Date: Wed, 1 Jul 2009 13:05:48 -0700 Subject: [PATCH] cli: webopen: when called with no arguments, open the Welcome page --- src/allmydata/scripts/cli.py | 2 +- src/allmydata/scripts/tahoe_webopen.py | 15 +++++++++------ src/allmydata/test/test_cli.py | 3 ++- 3 files changed, 12 insertions(+), 8 deletions(-) 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) -- 2.45.2