From 9bc87f610c5ed0913f7e913f24e79744dc4170d4 Mon Sep 17 00:00:00 2001
From: Zooko O'Whielacronx <zooko@zooko.com>
Date: Mon, 9 Jul 2007 18:27:11 -0700
Subject: [PATCH] tahoe-get.py: add optional target-local-file argument

---
 src/allmydata/scripts/tahoe-get.py | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/allmydata/scripts/tahoe-get.py b/src/allmydata/scripts/tahoe-get.py
index 5c92ef0e..fcc8c43d 100644
--- a/src/allmydata/scripts/tahoe-get.py
+++ b/src/allmydata/scripts/tahoe-get.py
@@ -2,9 +2,9 @@
 
 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")
@@ -13,6 +13,10 @@ parser.add_option("-s", "--server", dest="server", default="http://tahoebs1.allm
 (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/"
@@ -21,4 +25,7 @@ base += "/"
 
 url = base + vfname
 
-GET(url)
+if targfname is None:
+    GET(url, sys.stdout)
+else:
+    GET(url, open(targfname, "wb"))
-- 
2.45.2