tahoe mkdir
tahoe mkdir [alias:]path
tahoe ls [alias:][path]
+tahoe webopen [alias:]path
tahoe put [--mutable] [localfrom:-]
tahoe put [--mutable] [localfrom:-] [alias:]to
tahoe put [--mutable] [localfrom:-] [alias:]subdir/to
This lists a subdirectory of your filesystem.
+tahoe webopen tahoe:
+tahoe webopen tahoe:subdir/
+
+ This uses the python 'webbrowser' module to cause a local web browser to
+ open to the web page for the given directory. This page offers interfaces to
+ add, dowlonad, rename, and delete files in the directory.
+
tahoe put file.txt
tahoe put ./file.txt
tahoe put /tmp/file.txt
return "%s ln FROM TO" % (os.path.basename(sys.argv[0]),)
class WebopenOptions(VDriveOptions):
- def parseArgs(self, vdrive_pathname=""):
- self['vdrive_pathname'] = vdrive_pathname
+ def parseArgs(self, where=""):
+ self.where = where
longdesc = """Opens a webbrowser to the contents of some portion of the virtual drive."""
rc = tahoe_mv.mv(options, mode="link")
return rc
-def webopen(options):
+def webopen(options, opener=None):
import urllib, webbrowser
+ from allmydata.scripts.common import get_alias, DEFAULT_ALIAS, escape_path
nodeurl = options['node-url']
if nodeurl[-1] != "/":
nodeurl += "/"
- root_cap = options.aliases["tahoe"]
- url = nodeurl + "uri/%s/" % urllib.quote(root_cap)
- if options['vdrive_pathname']:
- url += urllib.quote(options['vdrive_pathname'])
- webbrowser.open(url)
+ where = options.where
+ if where.endswith("/"):
+ where = where[:-1]
+ rootcap, path = get_alias(options.aliases, where, DEFAULT_ALIAS)
+ url = nodeurl + "uri/%s" % urllib.quote(rootcap)
+ if path:
+ url += "/" + escape_path(path)
+ if url[-1] != "/":
+ url += "/"
+ if opener is None:
+ opener = webbrowser.open
+ opener(url)
return 0
def repl(options):
class CreateAlias(SystemTestMixin, CLITestMixin, unittest.TestCase):
+ def _test_webopen(self, args, expected_url):
+ woo = cli.WebopenOptions()
+ all_args = ["--node-directory", self.getdir("client0")] + list(args)
+ woo.parseOptions(all_args)
+ urls = []
+ rc = cli.webopen(woo, urls.append)
+ self.failUnlessEqual(rc, 0)
+ self.failUnlessEqual(len(urls), 1)
+ self.failUnlessEqual(urls[0], expected_url)
+
def test_create(self):
self.basedir = os.path.dirname(self.mktemp())
d = self.set_up_nodes()
self.failUnless("tahoe" in aliases)
self.failUnless(aliases["tahoe"].startswith("URI:DIR2:"))
d.addCallback(_done)
+ d.addCallback(lambda res: self.do_cli("create-alias", "two"))
+ def _stash_urls(res):
+ aliases = get_aliases(self.getdir("client0"))
+ node_url_file = os.path.join(self.getdir("client0"), "node.url")
+ nodeurl = open(node_url_file, "r").read().strip()
+ uribase = nodeurl + "uri/"
+ self.tahoe_url = uribase + urllib.quote(aliases["tahoe"]) + "/"
+ self.tahoe_subdir_url = self.tahoe_url + "subdir/"
+ self.two_url = uribase + urllib.quote(aliases["two"]) + "/"
+ d.addCallback(_stash_urls)
+
+ d.addCallback(lambda res: self._test_webopen([], self.tahoe_url))
+ d.addCallback(lambda res: self._test_webopen(["/"], self.tahoe_url))
+ d.addCallback(lambda res: self._test_webopen(["tahoe:"], self.tahoe_url))
+ d.addCallback(lambda res: self._test_webopen(["tahoe:/"], self.tahoe_url))
+ d.addCallback(lambda res: self._test_webopen(["tahoe:subdir"],
+ self.tahoe_subdir_url))
+ d.addCallback(lambda res: self._test_webopen(["tahoe:subdir/"],
+ self.tahoe_subdir_url))
+ d.addCallback(lambda res: self._test_webopen(["two:"], self.two_url))
+
return d
class Put(SystemTestMixin, CLITestMixin, unittest.TestCase):