From 6fa70befd5cb41c7e2d2a14b991fe91bad70d999 Mon Sep 17 00:00:00 2001 From: robk-tahoe Date: Fri, 4 Jan 2008 18:34:10 -0700 Subject: [PATCH] added "tahoe webopen" command taking the same arguments as tahoe ls, it does a webbrowser.open to the page specified by those args. hence "tahoe webopen" will open a browser to the root dir specified in private/root_dir.cap by default. this might be a good alternative to the start.html page. --- src/allmydata/scripts/cli.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/allmydata/scripts/cli.py b/src/allmydata/scripts/cli.py index beeff150..c5c4ef79 100644 --- a/src/allmydata/scripts/cli.py +++ b/src/allmydata/scripts/cli.py @@ -114,6 +114,11 @@ class MvOptions(VDriveOptions): def getSynopsis(self): return "%s mv FROM TO" % (os.path.basename(sys.argv[0]),) +class WebopenOptions(VDriveOptions): + def parseArgs(self, vdrive_pathname=""): + self['vdrive_pathname'] = vdrive_pathname + + longdesc = """Opens a webbrowser to the contents of some portion of the virtual drive.""" subCommands = [ ["ls", None, ListOptions, "List a directory"], @@ -121,6 +126,7 @@ subCommands = [ ["put", None, PutOptions, "Upload a file into the virtual drive."], ["rm", None, RmOptions, "Unlink a file or directory in the virtual drive."], ["mv", None, MvOptions, "Move a file within the virtual drive."], + ["webopen", None, WebopenOptions, "Open a webbrowser to the root_dir"], ] def list(config, stdout, stderr): @@ -192,11 +198,23 @@ def mv(config, stdout, stderr): stdout, stderr) return rc +def webopen(config, stdout, stderr): + import urllib, webbrowser + nodeurl = config['node-url'] + if nodeurl[-1] != "/": + nodeurl += "/" + url = nodeurl + "uri/%s/" % urllib.quote(config['dir-uri']) + if config['vdrive_pathname']: + url += urllib.quote(config['vdrive_pathname']) + webbrowser.open(url) + return 0 + dispatch = { "ls": list, "get": get, "put": put, "rm": rm, "mv": mv, + "webopen": webopen, } -- 2.45.2