This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import main, reactor | |
from twisted.internet.abstract import FileDescriptor | |
from twisted.internet.error import ConnectionDone | |
from twisted.internet.fdesc import writeToFD | |
from twisted.internet.interfaces import IReadDescriptor, IWriteDescriptor | |
from twisted.internet.protocol import Protocol | |
from twisted.python import log | |
from twisted.python.filepath import FilePath | |
from zope.interface import implements | |
import errno |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.internet import main, reactor | |
from twisted.internet.abstract import FileDescriptor | |
from twisted.internet.error import ConnectionDone | |
from twisted.internet.fdesc import setNonBlocking | |
from twisted.internet.interfaces import IReadDescriptor | |
from twisted.internet.protocol import Protocol | |
from twisted.python import log | |
from twisted.python.failure import Failure | |
from twisted.python.filepath import FilePath | |
from zope.interface import implements |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
@author: shylent | |
''' | |
from twisted.internet import reactor | |
from twisted.python import log | |
class Spent(Exception): | |
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExpectTelnetWrapper(object): | |
implements(ITelnetProtocol) | |
def __init__(self, expect): | |
""" | |
@param expect: Instance of L{Expect} class, that we are wrapping | |
@type expect: L{Expect} | |
""" | |
self.expect = expect | |
self.expect.transport = self |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_foo(request): | |
format_handlers = { | |
'xml':handle_foo_xml | |
} | |
format = request.GET.get('format', None) | |
if format is not None and format in format_handlers: | |
return format_handlers[format](request) | |
... | |
def handle_foo_xml(request): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from twisted.trial import unittest | |
from twisted.python import log | |
class DummyObserver(object): | |
def start(self): | |
log.addObserver(self.emit) | |
def stop(self): | |
log.removeObserver(self.emit) |