import optparse, sys, urllib
-def GET(url):
+def GET(url, outf):
f = urllib.urlopen(url)
- sys.stdout.write(f.read())
+ outf.write(f.read())
parser = optparse.OptionParser()
parser.add_option("-d", "--vdrive", dest="vdrive", default="global")
(options, args) = parser.parse_args()
vfname = args[0]
+if len(args) == 1 or args[1] == "-":
+ targfname = None
+else:
+ targfname = args[1]
base = "http://tahoebs1.allmydata.com:8011/"
base += "vdrive/"
url = base + vfname
-GET(url)
+if targfname is None:
+ GET(url, sys.stdout)
+else:
+ GET(url, open(targfname, "wb"))