twisted

Use alternate authentication in twisted's Perspective Broker

匿名 (未验证) 提交于 2019-12-03 09:58:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using twisted's Perspective Broker for a network application. I encountered the problem that it automatically uses an MD5 challenge-response scheme for authentication. Ideally I would prefer not to store MD5 hashes on the server-side due to a number of security vulnerabilities. Alternatively, scrypt, bcrypt or pbkdf2 provide more secure algorithms. However, while these algorithms are readily available in python, I don't quite see, whether it is possible to implement a custom authentication scheme using the Perspective Broker. Judging

How to run twisted with flask?

久未见 提交于 2019-12-03 09:57:30
问题 I wanna be able to run multiple twisted proxy servers on different directories on the same port simultaneously, and I figured I might use flask. so here's my code: from flask import Flask from twisted.internet import reactor from twisted.web import proxy, server app = Flask(__name__) @app.route('/example') def index(): site = server.Site(proxy.ReverseProxyResource('www.example.com', 80, ''.encode("utf-8"))) reactor.listenTCP(80, site) reactor.run() app.run(port=80, host='My_IP') But whenever

Twisted Python + spawnProcess. Getting output from a command

◇◆丶佛笑我妖孽 提交于 2019-12-03 09:09:02
I'm working to wrap the Minecraft server application with a Twisted Python server that has a RESTful API for getting the list of currently connected players. The Twisted app starts the minecraft server via reactor.spawnProcess() , then communicates via a ProcessTransport , which writes to stdin. Reading stdout and stdin is handled by a separate protocol.ProcessProtocol class. Given that I want to get the results of a very specific command (the 'list' command, which returns something like this: [INFO] Connected players: blah, blah2 If I am able to pick out a player list line in stdout, what is

HTTP Download very Big File

吃可爱长大的小学妹 提交于 2019-12-03 09:06:16
问题 I'm working at a web application in Python/Twisted. I want the user to be able to download a very big file (> 100 Mb). I don't want to load all the file in memory (of the server), of course. server side I have this idea: ... request.setHeader('Content-Type', 'text/plain') fp = open(fileName, 'rb') try: r = None while r != '': r = fp.read(1024) request.write(r) finally: fp.close() request.finish() I expected this to work, but I have problems: I'm testing with FF... It seems the browser make me

Python + Twisted + sqlanydb = abort()

匿名 (未验证) 提交于 2019-12-03 09:02:45
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using Twisted 11 together with SQLAnywhere 12 via the official sqlanydb driver. Generally, it works fine. But occasionally the application crashes with an abort on the first query. If one query worked, all following work too. However my tests run only seldom through. That's awful to develop with and strace doesn't tell me anything informative too. Sometimes it crashes inside of select(), sometimes in mmap()... I'm running 64bit Linux and run locally the Sybase as dbeng12 for testing. Is anyone working successfully using these components?

Twisted Python How To Create a twisted.web.client.BrowserLikePolicyForHTTPS with a custom trustRoot?

匿名 (未验证) 提交于 2019-12-03 08:48:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to create a t.w.c.BrowserLikePolicyForHTTPS to use as the ContextFactory for a t.w.c.Agent . I am using an internal CA for all the servers I want the Agent to communicate with, so I'd like to be able to tell to load the CA cert (PEM format) and use it as the trustRoot argument to BrowserLikePolicyForHTTPS . I have read the docs and looked at the source, but I have no idea what I am supposed to supply as arguments. I tried providing a PyOPenSSL x509 object, but I get an error: exceptions . TypeError : ( 'Could not adapt'

Twisted, MySQLdb and (2006, 'MySQL server has gone away') using Twisted adbapi

匿名 (未验证) 提交于 2019-12-03 08:28:06
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In twisted I am a perpetual event loop that is always lookig for a new query to run It polls a SQS queue and are are times where time between queres is long enough to time out and this is the error I get when a new query arrives... MySQLdb _mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away') here is my connection self.pool = adbapi.ConnectionPool("MySQLdb", self.parms['host'], self.parms['username'], self.parms['password'], self.parms['database']) Here is the logic I use to try and solve the problem. try: d = self.pool

Downloading files in twisted using queue

给你一囗甜甜゛ 提交于 2019-12-03 08:27:32
I want to download a many files from queue using twisted and (for example ) 20 clients-threads. Any example ? from twisted.internet.defer import inlineCallbacks, DeferredQueue @inlineCallbacks def worker(queue): while 1: url = yield queue.get() # wait for a url from the queue if url is None: # insert None into the queue to kill workers queue.put(None) return # done data = yield download(url) # download the file process(data) # do stuff with it queue = DeferredQueue() # your queue # make workers MAX = 20 workers = [worker(queue) for _ in range(MAX)] Here's a translation of https://github.com

Benefits of twisted-suds - Async way of using python suds soap lib

南笙酒味 提交于 2019-12-03 08:25:20
I'm using python suds library to make a SOAP client based on a local wsdl file. My goal is to use Twisted as the backend so I query the SOAP servers in a asyncronous way. I know this topic has been covered different times ( here1 , here2 ), but I still have some questions. I've seen three different approaches to use twisted with suds: a) Applying this patch to the suds library. b) Use twisted-suds , which is a fork of suds. c) Influenced by this post , I implemented Client_Async suds client using the twisted deferToThread operation, (fully working gist can be found here . I also implemented a

Asynchronous WSGI with Twisted

佐手、 提交于 2019-12-03 08:13:43
I'm building a web interface for a twisted application and would like to use WSGI rather than twisted.web directly (since the rest of the website is WSGI and I already have a substantial WSGI codebase). The Twisted documentation page I found about WSGIResource (http://twistedmatrix.com/documents/current/web/howto/web-in-60/wsgi.html) states: Like any other WSGI container, you can't do anything asynchronous in your WSGI applications, even though this is a Twisted WSGI container. Does this have to be true? Is there some less-than-hacky way of doing twisted.web style asynchronous web request