class VDriveOptions(BaseOptions, usage.Options):
optParameters = [
- ["vdrive", "d", "global",
- "which virtual drive to use: 'global' or 'private'"],
-
["node-url", "u", None,
"URL of the tahoe node to use, a URL like \"http://127.0.0.1:8888\""],
]
def list(config, stdout, stderr):
from allmydata.scripts import tahoe_ls
rc = tahoe_ls.list(config['node-url'],
- config['vdrive'],
config['vdrive_pathname'])
return rc
vdrive_filename = config['vdrive_filename']
local_filename = config['local_filename']
rc = tahoe_get.get(config['node-url'],
- config['vdrive'],
vdrive_filename,
local_filename)
if rc == 0:
else:
verbosity = 2
rc = tahoe_put.put(config['node-url'],
- config['vdrive'],
local_filename,
vdrive_filename,
verbosity)
else:
verbosity = 2
rc = tahoe_rm.rm(config['node-url'],
- config['vdrive'],
vdrive_pathname,
verbosity)
return rc
import sys, urllib
-def get(nodeurl, vdrive, vdrive_fname, local_file):
+def get(nodeurl, vdrive_fname, local_file):
if nodeurl[-1] != "/":
nodeurl += "/"
- url = nodeurl + "vdrive/" + vdrive + "/"
+ url = nodeurl + "vdrive/global/"
if vdrive_fname:
url += vdrive_fname
def main():
import optparse, re
parser = optparse.OptionParser()
- parser.add_option("-d", "--vdrive", dest="vdrive", default="global")
parser.add_option("-u", "--nodeurl", dest="nodeurl")
(options, args) = parser.parse_args()
if len(args) > 1:
local_file = args[1]
- get(options.nodeurl, options.vdrive, vdrive_fname, local_file)
+ get(options.nodeurl, vdrive_fname, local_file)
if __name__ == '__main__':
main()
import urllib
import simplejson
-def list(nodeurl, vdrive, vdrive_pathname):
+def list(nodeurl, vdrive_pathname):
if nodeurl[-1] != "/":
nodeurl += "/"
- url = nodeurl + "vdrive/" + vdrive + "/"
+ url = nodeurl + "vdrive/global/"
if vdrive_pathname:
url += vdrive_pathname
url += "?t=json"
def main():
import optparse, re
parser = optparse.OptionParser()
- parser.add_option("-d", "--vdrive", dest="vdrive", default="global")
parser.add_option("-u", "--node-url", dest="nodeurl")
(options, args) = parser.parse_args()
if args:
vdrive_pathname = args[0]
- list(options.nodeurl, options.vdrive, vdrive_pathname)
+ list(options.nodeurl, vdrive_pathname)
if __name__ == '__main__':
main()
SERVERURL_RE=re.compile("http://([^:]*)(:([1-9][0-9]*))?")
-def _put(serverurl, vdrive, vdrive_fname, local_fname, verbosity):
+def _put(serverurl, vdrive_fname, local_fname, verbosity):
"""
@param verbosity: 0, 1, or 2, meaning quiet, verbose, or very verbose
d = defer.Deferred()
- url = "/vdrive/" + vdrive + "/"
+ url = "/vdrive/global/"
if vdrive_fname:
url += vdrive_fname
if verbosity == 2:
if resp.code == 200:
- outbuf.append("modified existing mapping in vdrive %s of name %s to point to " % (vdrive, vdrive_fname,))
+ outbuf.append("modified existing mapping of name %s to point to " % (vdrive_fname,))
elif resp.code == 201:
- outbuf.append("created new mapping in vdrive %s of name %s to point to " % (vdrive, vdrive_fname,))
+ outbuf.append("created new mapping of name %s to point to " % (vdrive_fname,))
outbuf.append("URI: %s" % (uri,))
return d
-def put(server, vdrive, vdrive_fname, local_fname, verbosity):
+def put(server, vdrive_fname, local_fname, verbosity):
"""
This starts the reactor, does the PUT command, waits for the result, stops
the reactor, and returns the exit code.
@return: the exit code
"""
- d = _put(server, vdrive, vdrive_fname, local_fname, verbosity)
+ d = _put(server, vdrive_fname, local_fname, verbosity)
exitcode = [ None ]
def exit(result):
exitcode[0] = result
d.addCallbacks(exit, exit)
reactor.run()
return exitcode[0]
-
+
NODEURL_RE=re.compile("http://([^:]*)(:([1-9][0-9]*))?")
-def put(nodeurl, vdrive, local_fname, vdrive_fname, verbosity):
+def put(nodeurl, local_fname, vdrive_fname, verbosity):
"""
@param verbosity: 0, 1, or 2, meaning quiet, verbose, or very verbose
host = mo.group(1)
port = int(mo.group(3))
- url = "/vdrive/" + vdrive + "/"
+ url = "/vdrive/global/"
if vdrive_fname:
url += vdrive_fname
def main():
import optparse, re
parser = optparse.OptionParser()
- parser.add_option("-d", "--vdrive", dest="vdrive", default="global")
parser.add_option("-u", "--node-url", dest="nodeurl")
(options, args) = parser.parse_args()
if len(args) > 1:
vdrive_fname = args[1]
- return put(options.nodeurl, options.vdrive, vdrive_fname, local_file)
+ return put(options.nodeurl, vdrive_fname, local_file)
if __name__ == '__main__':
main()
NODEURL_RE=re.compile("http://([^:]*)(:([1-9][0-9]*))?")
-def rm(nodeurl, vdrive, vdrive_pathname, verbosity):
+def rm(nodeurl, vdrive_pathname, verbosity):
"""
@param verbosity: 0, 1, or 2, meaning quiet, verbose, or very verbose
host = mo.group(1)
port = int(mo.group(3))
- url = "/vdrive/" + vdrive + "/"
+ url = "/vdrive/global/"
if vdrive_pathname:
url += vdrive_pathname
def main():
import optparse, re
parser = optparse.OptionParser()
- parser.add_option("-d", "--vdrive", dest="vdrive", default="global")
parser.add_option("-u", "--node-url", dest="nodeurl")
(options, args) = parser.parse_args()
vdrive_pathname = args[0]
- return rm(options.nodeurl, options.vdrive, vdrive_pathname, 0)
+ return rm(options.nodeurl, vdrive_pathname, 0)
if __name__ == '__main__':
main()