twisted

Scrapy Twisted ConnectionLost error

旧街凉风 提交于 2019-12-11 17:23:48
问题 I am learning scrapy and am having a hard time trying to figure out this issue. My spider will not crawl the macys website and keeps throwing the following error: [<twisted.python.failure.Failure twisted.internet.error.ConnectionLost: Connection to the other side was lost in a non-clean fashion: Connection lost.>] Things I've tried so far: Setting headers and robotstxt obey per this thread: Scrapy Shell: twisted.internet.error.ConnectionLost although USER_AGENT is set Changing the user agent

How refactor readChunk from SFTPFile to stop using inlineCallbacks?

£可爱£侵袭症+ 提交于 2019-12-11 16:21:16
问题 I'm trying to read from file over ISFTPFile and I want to avoid using @inlinceCallbacks in this scenario? Or maybe there is a better way to read/write for ISFTPFile ? @defer.inlineCallbacks def calculate_checksum(open_file): hasher = hashlib.sha256() offset = 0 try: while True: d = yield open_file.readChunk(offset, chunk_size) offset += chunk_size hasher.update(d) except EOFError: pass target_checksum = hasher.hexdigest() defer.returnValue(target_checksum) client_file = client.openFile(

Corona Simulator stop working after connecting to server

北城以北 提交于 2019-12-11 14:27:36
问题 I have 2 server file work with corona simulator. One is work but another isn't. Not sure what is the different between these 2 file. Below is my server code. Non-working: class Chat(Protocol): def connectionMade(self): self.factory.clients.append(self) def connectionLost(self, reason): self.factory.clients.remove(self) def dataReceived(self,data): for c in self.factory.clients: c.message(data) print data def message(self, data): self.transport.write(data) factory = Factory() factory.clients =

Convert the input from telnet to a list in twisted

こ雲淡風輕ζ 提交于 2019-12-11 14:17:52
问题 input from telnet GET /learn/tutorials/351079-weekend-project-secure-your-system-with-port-knocking?name=MyName&married=not+single&male=yes HTTP/1.1 Host: merch1.localhost User-Agent: Mozilla/5.0 (Windows;en-GB; rv:1.8.0.11) Gecko/20070312 Firefox/1.5.0.11 Accept: text/xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-gb,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive how can i get this

Twisted + Gtk - shutdown not working properly

只谈情不闲聊 提交于 2019-12-11 12:54:13
问题 Using Python 2.6, Twisted 10.1, and GTK+ 2.22, with latest pygtk installed, I'm having problems on shutdown. When I close my application and shut down the reactor (using the gtk2reactor of course), the application simply freezes. I've poked around the twisted source and added debug messages. What ends up happening is, the 'shutdown' event fires, PortableGtkReactor.crash is called, which calls gtk.main_quit . The event gets processed at the end of ReactorBase.runUntilCurrent . When the

Calling publish from outside a custom Autobahn WampClientProtocol

陌路散爱 提交于 2019-12-11 11:34:04
问题 How do I call an autobahn/wamp/twisted protocol publish method from outside of the protocol class? I have a custom python autobahn client based on https://github.com/tavendo/AutobahnPython/blob/master/examples/wamp/pubsub/custom/client.py. I am attempting to publish an event from outside of the custom WampClientProtocol class and am having trouble. If I assign the protcol object to a variable, line 1387 of wamp.py (https://github.com/tavendo/AutobahnPython/blob/master/autobahn/autobahn/wamp

TLS in Twisted Python - How to create server.pem?

喜你入骨 提交于 2019-12-11 10:44:21
问题 I've just discovered Twisted in Python, and have been looking at the echoserv_ssl.py sample as found here: https://twistedmatrix.com/documents/14.0.0/core/howto/ssl.html. Just above the sample code, the page quotes "The following examples rely on the files server.pem (private key and self-signed certificate together) and public.pem (the server’s public certificate by itself)." So being something of a novice when it comes to SSL certs and keys, I did some research, and found http://www

Twisted pipe two processes with spawnProcess

自作多情 提交于 2019-12-11 10:04:54
问题 I'm trying to use Twisted with Python2.7 for piping two processes. What I'd like to do is: myImagesPipesGenerator | ffmpeg -i - myImagesPipesGenerator is outputing on stdout an infinite list of BMP images. FFmpeg is getting those pictures on stdin and encoding them in a video So I need to: generatorTransport = reactor.spawnProcess(myInputProtocol, "myImagesPipesGenerator", ["myImagesPipesGenerator",], env=None, childFDs={0:'w', 1:'r', 2:'r'}) ffmpegTransport = reactor.spawnProcess

How do I switch this Proxy to use Proxy-Authentication?

心不动则不痛 提交于 2019-12-11 09:47:43
问题 I'm trying to modify my simple Twisted web proxy to use "Proxy-Authentication" (username/password) instead of the current IP based authentication. Problem is, I'm new to Twisted and don't even know where to start. Here is my Factory Class. class ProxyFactory(http.HTTPFactory): def __init__(self, ip, internal_ips): http.HTTPFactory.__init__(self) self.ip = ip self.protocol = proxy.Proxy self.INTERNAL_IPS = internal_ips def buildProtocol(self, addr): print addr # IP based authentication -- need

python twisted: enforcing a single connection per id

佐手、 提交于 2019-12-11 09:35:24
问题 I have a twisted server using SSL sockets and using certificates to identify the different clients that connect to the server. I'd like to enforce the state where there is only one connection by each possible id. The two ways I can think of is to keep track of connected ids and then not allow a second connection by the same id or allow the second connection and immediately terminate the first. I'm trying to do the later but am having some issues (I'll explain my choice at the end) I'm storing