From: robk-tahoe Date: Sat, 5 Jan 2008 01:34:10 +0000 (-0700) Subject: added "tahoe webopen" command X-Git-Tag: allmydata-tahoe-0.7.0~30 X-Git-Url: https://git.rkrishnan.org/%5B/%5D%20/uri/flags/statistics?a=commitdiff_plain;h=6fa70befd5cb41c7e2d2a14b991fe91bad70d999;p=tahoe-lafs%2Ftahoe-lafs.git 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. --- 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, }