removed unused utils
This commit is contained in:
parent
faf5c63c14
commit
76de29a217
@ -1,22 +1,9 @@
|
|||||||
#coding:utf8
|
#coding:utf8
|
||||||
|
|
||||||
from functools import wraps
|
|
||||||
try:
|
|
||||||
from cStringIO import StringIO
|
|
||||||
except ImportError:
|
|
||||||
from StringIO import StringIO
|
|
||||||
|
|
||||||
from twisted.internet.defer import succeed
|
|
||||||
from twisted.internet.protocol import (
|
|
||||||
ProcessProtocol,
|
|
||||||
Protocol,
|
|
||||||
)
|
|
||||||
from twisted.protocols.basic import LineReceiver
|
|
||||||
from twisted.web.iweb import IBodyProducer
|
|
||||||
|
|
||||||
from zope.interface import implements
|
|
||||||
|
|
||||||
from .utils import ArgumentParser
|
from .utils import ArgumentParser
|
||||||
|
from functools import wraps
|
||||||
|
from twisted.internet.protocol import ProcessProtocol
|
||||||
|
from twisted.protocols.basic import LineReceiver
|
||||||
|
|
||||||
def argumentCount(minimum, maximum=None):
|
def argumentCount(minimum, maximum=None):
|
||||||
def decorator(f):
|
def decorator(f):
|
||||||
@ -113,47 +100,3 @@ class LineProcessProtocol(ProcessProtocol):
|
|||||||
self.transport.write(line+'\n')
|
self.transport.write(line+'\n')
|
||||||
|
|
||||||
|
|
||||||
class BodyProducer(object):
|
|
||||||
implements(IBodyProducer)
|
|
||||||
|
|
||||||
def __init__(self, body):
|
|
||||||
self.body = body
|
|
||||||
self.length = len(body)
|
|
||||||
|
|
||||||
def startProducing(self, consumer):
|
|
||||||
consumer.write(self.body)
|
|
||||||
return succeed(None)
|
|
||||||
|
|
||||||
def pauseProducing(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def stopProducing(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
class BodyGetter(Protocol):
|
|
||||||
def __init__(self, length, callback):
|
|
||||||
self.length = length
|
|
||||||
self.callback = callback
|
|
||||||
self.body = StringIO()
|
|
||||||
|
|
||||||
def dataReceived(self, data):
|
|
||||||
if self.length > 0:
|
|
||||||
data = data[:self.length]
|
|
||||||
self.body.write(data)
|
|
||||||
self.length -= self.body.len #TODO: need fixing! chuj wie jak to działa :D
|
|
||||||
|
|
||||||
def connectionLost(self, reason):
|
|
||||||
self.callback(self.body.getvalue())
|
|
||||||
|
|
||||||
def null_response_handler(status, headers, body):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def handle_response(callback):
|
|
||||||
def defer_callback(response):
|
|
||||||
status = response.code
|
|
||||||
headers = response.headers.getAllRawHeaders()
|
|
||||||
def body_callback(body):
|
|
||||||
callback(status, headers, body)
|
|
||||||
response.deliverBody(BodyGetter(response.length, body_callback))
|
|
||||||
return defer_callback
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user