欢迎大家赞助一杯啤酒🍺 我们准备了下酒菜:Formal mathematics/Isabelle/ML, Formal verification/Coq/ACL2/Agda, C++/Lisp/Haskell
Twisted
来自开放百科 - 灰狐
(版本间的差异)
小 (→链接) |
|||
| (未显示1个用户的24个中间版本) | |||
| 第1行: | 第1行: | ||
| + | {{top news}} | ||
| + | {{SeeWikipedia|Twisted (software)}} | ||
| + | |||
Twisted is an event-driven networking framework written in Python and licensed under the MIT license. | Twisted is an event-driven networking framework written in Python and licensed under the MIT license. | ||
[[Image:twisted-overview.png|thumb|right|High-Level Overview of Twisted]] | [[Image:twisted-overview.png|thumb|right|High-Level Overview of Twisted]] | ||
| − | == | + | ==Guide== |
http://twistedmatrix.com/trac/wiki/Downloads | http://twistedmatrix.com/trac/wiki/Downloads | ||
| − | + | wget http://tmrc.mit.edu/mirror/twisted/Twisted/2.5/Twisted-2.5.0.tar.bz2 | |
| − | *http://twistedmatrix.com | + | bunzip2 Twisted-2.5.0.tar.bz2 |
| − | * | + | tar xvf Twisted-2.5.0.tar |
| + | cd Twisted-2.5.0 | ||
| + | cd zope.interface-3.3.0 | ||
| + | python setup.py install | ||
| + | cd .. | ||
| + | python setup.py install | ||
| + | $ trial twisted // [http://twistedmatrix.com/projects/core/documentation/howto/testing.html Trial is Twisted's testing framework.] | ||
| + | >>> from twisted.web.client import getPage | ||
| + | >>> from twisted.internet import reactor | ||
| + | >>> def printContents(contents): | ||
| + | print "The Deferred has called printContents with the following contents:" | ||
| + | print contents | ||
| + | reactor.stop() | ||
| + | >>> deferred = getPage('http://www.huihoo.com/') | ||
| + | >>> deferred.addCallback(printContents) | ||
| + | <Deferred at 0xb9afd0> | ||
| + | >>> reactor.run() | ||
| + | ==Projects== | ||
| + | *Twisted: Asynchronous networking framework | ||
| + | *[[Twisted Conch]]: An SSH and SFTP protocol implementation together with clients and servers | ||
| + | *[[Twisted Web]]: An HTTP protocol implementation together with clients and servers | ||
| + | *[[Twisted Web2]]: An HTTP/1.1 Server Framework | ||
| + | *[[Twisted Mail]]: An SMTP, IMAP and POP protocol implementation together with clients and servers | ||
| + | *[[Twisted Names]]: A DNS protocol implementation with client and server | ||
| + | *[[Twisted News]]: An NNTP protocol implementation with client and server | ||
| + | *[[Twisted Words]]: Chat and Instant Messaging | ||
| + | *[[Twisted Lore]]: Documentation generator with HTML and LaTeX support | ||
| + | *[[Twisted Flow]]: Generator based asynchronous result flows (unmaintained) | ||
| + | *[[Twisted Pair]]: Low-level stuff (unmaintained) | ||
| + | *[[Twisted Runner]]: Process management, including an inetd server | ||
| + | http://twistedmatrix.com/projects/ | ||
| + | ==Writing Applicatons== | ||
| + | ===Creating XML-RPC server=== | ||
| + | Server: touch twisted-xmlrpc.py | ||
| + | from twisted.web import xmlrpc, server | ||
| + | class Example(xmlrpc.XMLRPC): | ||
| + | """An example object to be published.""" | ||
| + | def xmlrpc_echo(self, x): | ||
| + | """Return all passed args.""" | ||
| + | return x | ||
| + | def xmlrpc_add(self, a, b): | ||
| + | """Return sum of arguments.""" | ||
| + | return a + b | ||
| + | if __name__ == '__main__': | ||
| + | from twisted.internet import reactor | ||
| + | r = Example() | ||
| + | reactor.listenTCP(7080, server.Site(r)) | ||
| + | reactor.run( | ||
| + | python twisted-xmlrpc.py | ||
| + | |||
| + | Client: run client | ||
| + | >>> from twisted.web import xmlrpc, server | ||
| + | >>> import xmlrpclib | ||
| + | >>> s = xmlrpclib.Server('http://localhost:7080/') | ||
| + | >>> s.echo('huihoo') | ||
| + | 'huihoo' | ||
| + | >>> s.add(1,2) | ||
| + | 3 | ||
| + | ===Writing TCP server=== | ||
| + | TCPServer.py TCPClient.py | ||
| + | Services which allow you to make connections and listen for connections on TCP ports. | ||
| + | listenTCP | ||
| + | connectTCP | ||
| + | http://twistedmatrix.com/projects/core/documentation/howto/application.html | ||
| + | |||
| + | Server: 192.168.1.3 , Debian 3.1 | ||
| + | ===Writing TCP client=== | ||
| + | Client: 192.168.1.2 , WinXP | ||
| + | ==Software that uses Twisted== | ||
| + | *[[BitTorrent]] - a peer-to-peer file sharing program. | ||
| + | *[[BuildBot]] - a distributed building/testing framework. | ||
| + | *[[Python Director]] - pure Python tcp load balancer. | ||
| + | *[[Freevo]] - open-source home theatre and PVR PC platform. | ||
| + | *[[NXLucene]] - a standalone multi-threaded Lucene-based text indexing server. | ||
| + | *[[Zenoss]] - open source network/systems monitoring and management | ||
| + | More details: http://twistedmatrix.com/trac/wiki/ProjectsUsingTwisted | ||
| + | ==文档== | ||
| + | *[http://docs.huihoo.com/python/pycon/2014/an-introduction-to-twisted.pdf An Introduction to Twisted] | ||
| + | |||
| + | ==图集== | ||
| + | |||
| + | ==链接== | ||
| + | *[http://twistedmatrix.com Twisted官网] | ||
| + | *[https://github.com/twisted/twisted Twisted @ GitHub] | ||
| + | *http://download.huihoo.com/twisted/ | ||
| + | *http://docs.huihoo.com/twisted/ | ||
| + | |||
| + | [[category:framework]] | ||
| + | [[category:python]] | ||
| + | [[category:event]] | ||
2020年11月27日 (五) 00:48的最后版本
| |
您可以在Wikipedia上了解到此条目的英文信息 Twisted Thanks, Wikipedia. |
Twisted is an event-driven networking framework written in Python and licensed under the MIT license.
目录 |
[编辑] Guide
http://twistedmatrix.com/trac/wiki/Downloads wget http://tmrc.mit.edu/mirror/twisted/Twisted/2.5/Twisted-2.5.0.tar.bz2 bunzip2 Twisted-2.5.0.tar.bz2 tar xvf Twisted-2.5.0.tar cd Twisted-2.5.0 cd zope.interface-3.3.0 python setup.py install cd .. python setup.py install $ trial twisted // Trial is Twisted's testing framework. >>> from twisted.web.client import getPage >>> from twisted.internet import reactor >>> def printContents(contents): print "The Deferred has called printContents with the following contents:" print contents reactor.stop() >>> deferred = getPage('http://www.huihoo.com/') >>> deferred.addCallback(printContents) <Deferred at 0xb9afd0> >>> reactor.run()
[编辑] Projects
- Twisted: Asynchronous networking framework
- Twisted Conch: An SSH and SFTP protocol implementation together with clients and servers
- Twisted Web: An HTTP protocol implementation together with clients and servers
- Twisted Web2: An HTTP/1.1 Server Framework
- Twisted Mail: An SMTP, IMAP and POP protocol implementation together with clients and servers
- Twisted Names: A DNS protocol implementation with client and server
- Twisted News: An NNTP protocol implementation with client and server
- Twisted Words: Chat and Instant Messaging
- Twisted Lore: Documentation generator with HTML and LaTeX support
- Twisted Flow: Generator based asynchronous result flows (unmaintained)
- Twisted Pair: Low-level stuff (unmaintained)
- Twisted Runner: Process management, including an inetd server
http://twistedmatrix.com/projects/
[编辑] Writing Applicatons
[编辑] Creating XML-RPC server
Server: touch twisted-xmlrpc.py
from twisted.web import xmlrpc, server
class Example(xmlrpc.XMLRPC):
"""An example object to be published."""
def xmlrpc_echo(self, x):
"""Return all passed args."""
return x
def xmlrpc_add(self, a, b):
"""Return sum of arguments."""
return a + b
if __name__ == '__main__':
from twisted.internet import reactor
r = Example()
reactor.listenTCP(7080, server.Site(r))
reactor.run(
python twisted-xmlrpc.py
Client: run client
>>> from twisted.web import xmlrpc, server
>>> import xmlrpclib
>>> s = xmlrpclib.Server('http://localhost:7080/')
>>> s.echo('huihoo')
'huihoo'
>>> s.add(1,2)
3
[编辑] Writing TCP server
TCPServer.py TCPClient.py Services which allow you to make connections and listen for connections on TCP ports.
listenTCP connectTCP
http://twistedmatrix.com/projects/core/documentation/howto/application.html
Server: 192.168.1.3 , Debian 3.1
[编辑] Writing TCP client
Client: 192.168.1.2 , WinXP
[编辑] Software that uses Twisted
- BitTorrent - a peer-to-peer file sharing program.
- BuildBot - a distributed building/testing framework.
- Python Director - pure Python tcp load balancer.
- Freevo - open-source home theatre and PVR PC platform.
- NXLucene - a standalone multi-threaded Lucene-based text indexing server.
- Zenoss - open source network/systems monitoring and management
More details: http://twistedmatrix.com/trac/wiki/ProjectsUsingTwisted
[编辑] 文档
[编辑] 图集
[编辑] 链接
分享您的观点