]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
tahoe_put-web2ish.py: clean up imports to be pyflakes-compliant, add newline to output
authorBrian Warner <warner@allmydata.com>
Fri, 17 Aug 2007 00:47:52 +0000 (17:47 -0700)
committerBrian Warner <warner@allmydata.com>
Fri, 17 Aug 2007 00:47:52 +0000 (17:47 -0700)
src/allmydata/scripts/tahoe_put-web2ish.py

index 9f6cc11391bafaf082fb0c680fd8763e1a43d087..157853a1adf7ed95469ef24be05aec52154e4460 100644 (file)
@@ -2,10 +2,8 @@
 
 import re, sys
 
-from twisted import web2 
-from twisted.web2 import client, http, stream
-import twisted.web2.client.http
-
+from twisted.web2 import stream
+from twisted.web2.client.http import HTTPClientProtocol, ClientRequest
 from twisted.internet import defer, reactor, protocol
 
 SERVERURL_RE=re.compile("http://([^:]*)(:([1-9][0-9]*))?")
@@ -32,9 +30,9 @@ def _put(serverurl, vdrive, vdrive_fname, local_fname, verbosity):
         infileobj = sys.stdin
     else:
         infileobj = open(local_fname, "rb")
-    instream = web2.stream.FileStream(infileobj)
+    instream = stream.FileStream(infileobj)
     
-    d2 = protocol.ClientCreator(reactor, web2.client.http.HTTPClientProtocol).connectTCP(host, port)
+    d2 = protocol.ClientCreator(reactor, HTTPClientProtocol).connectTCP(host, port)
 
     def got_resp(resp):
         # If this isn't a 200 or 201, then write out the response data and
@@ -46,7 +44,7 @@ def _put(serverurl, vdrive, vdrive_fname, local_fname, verbosity):
             def exit(dummy):
                 d.errback(resp.code)
 
-            return web2.http.stream.readStream(resp.stream, writeit).addCallback(exit)
+            return stream.readStream(resp.stream, writeit).addCallback(exit)
 
         # If we are in quiet mode, then just exit with the resp.code.
         if verbosity == 0:
@@ -75,13 +73,14 @@ def _put(serverurl, vdrive, vdrive_fname, local_fname, verbosity):
             outbuf.append("URI: %s" % (uri,))
         
             sys.stdout.write(''.join(outbuf))
+            sys.stdout.write("\n")
 
             d.callback(resp.code)
 
-        web2.http.stream.readStream(resp.stream, gather_uri).addCallback(output_result)
+        stream.readStream(resp.stream, gather_uri).addCallback(output_result)
                 
     def send_req(proto):
-        proto.submitRequest(web2.client.http.ClientRequest('PUT', url, {}, instream)).addCallback(got_resp)
+        proto.submitRequest(ClientRequest('PUT', url, {}, instream)).addCallback(got_resp)
 
     d2.addCallback(send_req)