twisted

How do you create a simple Google Talk Client using the Twisted Words Python library?

大憨熊 提交于 2019-11-30 06:38:38
I am interested in making a Google Talk client using Python and would like to use the Twisted libraries Words module. I have looked at the examples, but they don't work with the current implementation of Google Talk. Has anybody had any luck with this? Would you mind documenting a brief tutorial? As a simple task, I'd like to create a client/bot that tracks the Online time of my various Google Talk accounts so that I can get an aggregate number. I figure I could friend the bot in each account and then use the XMPP presence information to keep track of the times that I can then aggregate.

Stop twisted reactor on a condition

社会主义新天地 提交于 2019-11-30 05:01:17
Is there a way to stop the twisted reactor when a certain condition is reached. For example, if a variable is set to certain value, then the reactor should stop? Jerub Ideally, you wouldn't set the variable to a value and stop the reactor, you'd call reactor.stop() . Sometimes you're not in the main thread, and this isn't allowed, so you might need to call reactor.callFromThread . Here are three working examples: # in the main thread: reactor.stop() # in a non-main thread: reactor.callFromThread(reactor.stop) # A looping call that will stop the reactor on a variable being set, # checking every

How do I catch errors with scrapy so I can do something when I get User Timeout error?

不羁的心 提交于 2019-11-30 05:00:21
ERROR: Error downloading <GET URL_HERE>: User timeout caused connection failure. I get this issue every now and then when using my scraper. Is there a way I can catch this issue and run a function when it happens? I can't find out how to do it online anywhere. What you can do is define an errback in your Request instances: errback (callable) – a function that will be called if any exception was raised while processing the request. This includes pages that failed with 404 HTTP errors and such. It receives a Twisted Failure instance as first parameter. Here's some sample code (for scrapy 1.0)

部署Twisted应用程序笔记

扶醉桌前 提交于 2019-11-30 04:16:44
部署Twisted Application 概述 Twisted提供了一套扩平台、高扩展的基于服务器和客户端模式的应用程序框架。本文看重Twisted框架在应用程序部署上的特点。另外,Twisted是Python语言所写,提供了除顺序、并发模型之外的事件驱动模型,结构简单、易用。 Twisted Application Framework 组成部分 服务 应用程序 TAC文件( Twisted Application Configuration) 插件 twistd命令行工具 服务 Twisted使用了zope interface,因此,该处的服务(service)与接口有关系,即实现了IService的类即为服务。IService提供了两个接口 startService stopService 服务和应用程序的关系:一个或多个服务可以组建成为一个application 应用程序 application作为容器类型存在,容纳一个或多个service。服务在application中注册,通过后文所述的twistd来检索和运行。 TAC 文件列表 传统上,开发者负责Twisted的启停和配置。在Twisted Application Framework中,协议实现和启停、配置分开,其中协议实现在普通的python文件中,而启停、配置在TAC文件中

Web interface for a twisted application

回眸只為那壹抹淺笑 提交于 2019-11-30 04:09:35
I have a application written in Twisted and I want to add a web interface to control and monitor it. I'll need plenty of dynamic pages that show the current status and configuration, so I hoped for a framework that offers at least a templating language with inheritance and some basic routing. Since I am using Twisted anyways I wanted to use twisted.web - but it's templating language is too basic and it seems that the only framework, Nevow is quite dead (it's on launchpad but the homepage and wiki are down and I can't find any documentation). So what are my options? Is there any other twisted

Twisted(asynch server) vs Django(or any other framework)

僤鯓⒐⒋嵵緔 提交于 2019-11-30 03:59:35
I need help understanding what the advantage of using an asynch framework is. Suppose I want to develop a simple chat web app. Why cant I write python code in the Django framework that does long polling where I dont send a response back the server until someone enters a new msg. What does Twisted provide that gives it an advantage for real-time apps like the chat app? Sorry I am obviously little confused about the need for an asynchronous framework. Asynchronous servers support much larger numbers of simultaneous client connections. More conventional servers come up against thread and process

Python: How can I use Twisted as the transport for SUDS?

大憨熊 提交于 2019-11-30 03:49:31
I have a project that is based on Twisted used to communicate with network devices and I am adding support for a new vendor ( Citrix NetScaler ) whose API is SOAP. Unfortunately the support for SOAP in Twisted still relies on SOAPpy , which is badly out of date. In fact as of this question (I just checked), twisted.web.soap itself hasn't even been updated in 21 months! I would like to ask if anyone has any experience they would be willing to share with utilizing Twisted's superb asynchronous transport functionality with SUDS. It seems like plugging in a custom Twisted transport would be a

How do you you run a Twisted application via Python (instead of via Twisted)?

梦想的初衷 提交于 2019-11-29 23:35:56
I am working my way through learning Twisted, and have stumbled across something I'm not sure I'm terribly fond of - the "Twisted Command Prompt". I am fiddling around with Twisted on my Windows machine, and tried running the "Chat" example: from twisted.protocols import basic class MyChat(basic.LineReceiver): def connectionMade(self): print "Got new client!" self.factory.clients.append(self) def connectionLost(self, reason): print "Lost a client!" self.factory.clients.remove(self) def lineReceived(self, line): print "received", repr(line) for c in self.factory.clients: c.message(line) def

ImportError with cx_Freeze and pyinstaller

好久不见. 提交于 2019-11-29 23:19:07
问题 I was using pyinstaller before to try and get my app with twisted as an executable, but I got this error when executing: Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/cx_Freeze/initscripts/Console.py", line 27, in <module> exec code in m.__dict__ File "client_test.py", line 2, in <module> File "/usr/local/lib/python2.7/dist-packages/Twisted-13.0.0-py2.7-linux-x86_64.egg/twisted/__init__.py", line 53, in <module> _checkRequirements() File "/usr/local/lib

How to make Twisted use Python logging?

♀尐吖头ヾ 提交于 2019-11-29 23:02:24
I've got a project where I'm using Twisted for my web server. When exceptions occur (such as network errors), it's printing to the console. I've already got logging through Python's built-in log module - is there any way to tell the reactor to use that instead? What's the usual pattern for this? Found it. It's actually quite easy: from twisted.python import log observer = log.PythonLoggingObserver(loggerName='logname') observer.start() You just set loggerName to the same logger name that you're using in logging.getLogger(). You can use twisted.python.log . For example: from twisted.python