From: Brian Warner Date: Fri, 17 Aug 2007 00:47:52 +0000 (-0700) Subject: tahoe_put-web2ish.py: clean up imports to be pyflakes-compliant, add newline to output X-Git-Url: https://git.rkrishnan.org/pf/content/en/seg/class-simplejson.JSONDecoder-index.html?a=commitdiff_plain;h=3e2d1e28eb0103be0960af5f79dc07f8f6c09c86;p=tahoe-lafs%2Ftahoe-lafs.git tahoe_put-web2ish.py: clean up imports to be pyflakes-compliant, add newline to output --- diff --git a/src/allmydata/scripts/tahoe_put-web2ish.py b/src/allmydata/scripts/tahoe_put-web2ish.py index 9f6cc113..157853a1 100644 --- a/src/allmydata/scripts/tahoe_put-web2ish.py +++ b/src/allmydata/scripts/tahoe_put-web2ish.py @@ -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)