rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return "fake", "fake", 80 | return address.IPv4Address("TCP", "fake", 80) | def getHost(self): return "fake", "fake", 80 |
@rtype: C{Deferred} @return: The callback of the C{Deferred} that is returned will be passed a string that represents the IP address of the specified name, or the errback will be called if the lookup times out. If multiple types of address records are associated with the name, A6 records will be returned in preference... | @rtype: L{twisted.internet.defer.Deferred} @return: The callback of the Deferred that is returned will be passed a string that represents the IP address of the specified name, or the errback will be called if the lookup times out. If multiple types of address records are associated with the name, A6 records will be re... | def getHostByName(self, name, timeout = 10): """Resolve the domain name C{name} into an IP address. |
"""Connects a L{ConnectedDatagramProtocol} instance to a UDP port. | """Connects a L{twisted.internet.protocol.ConnectedDatagramProtocol} instance to a UDP port. | def connectUDP(self, remotehost, remoteport, protocol, localport=0, interface='', maxPacketSize=8192): """Connects a L{ConnectedDatagramProtocol} instance to a UDP port. """ |
@param processProtocol: a L{ProcessProtocol} instance | @param processProtocol: a L{twisted.internet.protocol.ProcessProtocol} instance | def spawnProcess(self, processProtocol, executable, args=(), env={}, path=None, uid=None, gid=None, usePTY=0): """Spawn a process, with a process protocol. |
"""Return a L{Deferred} that will resolve a hostname. | """Return a L{twisted.internet.defer.Deferred} that will resolve a hostname. | def resolve(self, name, timeout=10): """Return a L{Deferred} that will resolve a hostname. """ |
@precondition ttl must be > 0 and <= MAXUINT8.: (ttl > 0) and (ttl <= MAXUINT8): "ttl: %s" % str(ttl) | Precondition: ttl must be > 0 and <= MAXUINT8.: (ttl > 0) and (ttl <= MAXUINT8): "ttl: %s" % str(ttl) | def sendPing(self, ttl): """ @precondition ttl must be > 0 and <= MAXUINT8.: (ttl > 0) and (ttl <= MAXUINT8): "ttl: %s" % str(ttl) """ assert (ttl > 0) and (ttl <= MAXUINT8), "ttl must be > 0 and <= MAXUINT8." + " -- " + "ttl: %s" % str(ttl) log.msg("%s.sendPing(%s)" % (str(self), str(ttl),)) self.sendDescriptor(self._... |
@precondition ttl must be > 0 and <= MAXUINT8.: (ttl > 0) and (ttl <= MAXUINT8): "ttl: %s" % str(ttl) @precondition descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(de... | Precondition: ttl must be > 0 and <= MAXUINT8.: (ttl > 0) and (ttl <= MAXUINT8): "ttl: %s" % str(ttl) Precondition: descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(de... | def sendPong(self, ttl, descriptorId, host, port, numberOfFilesShared, kbShared): """ @precondition ttl must be > 0 and <= MAXUINT8.: (ttl > 0) and (ttl <= MAXUINT8): "ttl: %s" % str(ttl) @precondition descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descripto... |
@precondition descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId)),) | Precondition: descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId)),) | def pingReceived(self, descriptorId, ttl, hops): """ Override this to handle ping messages. @precondition descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId... |
@param ipAddress a string representing an IPv4 address like this "140.184.83.37"; This is the representation that the Python Standard Library's socket.connect() expects. @param port an integer port number @param numberOfFilesShared a long @param kbShared a long @precondition descriptorId must be a string of length DES... | @param ipAddress: a string representing an IPv4 address like this "140.184.83.37"; This is the representation that the Python Standard Library's socket.connect() expects. @param port: an integer port number @param numberOfFilesShared: a long @param kbShared: a long Precondition: descriptorId must be a string of length... | def pongReceived(self, descriptorId, ttl, hops, ipAddress, port, numberOfFilesShared, kbShared): """ Override this to handle pong messages. |
@param searchCriteria a string @param minimumSpeed integer KB/s -- you are not supposed to respond to this query if you can't serve at least this fast @precondition descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descript... | Precondition: descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId)),) @param searchCriteria: a string @param minimumSpeed: integer KB/s -- you are not suppo... | def queryReceived(self, descriptorId, ttl, hops, searchCriteria, minimumSpeed): """ Override this to handle query messages. @param searchCriteria a string @param minimumSpeed integer KB/s -- you are not supposed to respond to this query if you can't serve at least this fast |
@param ipAddress a string representing an IPv4 address like this "140.184.83.37"; This is the representation that the Python Standard Library's socket.connect() expects. @param port an integer port number @param resultSet a list of tuples of (fileIndex, fileSize, fileName,) where fileIndex is a long, fileSize (in bytes... | @param ipAddress: a string representing an IPv4 address like this "140.184.83.37"; This is the representation that the Python Standard Library's socket.connect() expects. @param port: an integer port number @param resultSet: a list of tuples of (fileIndex, fileSize, fileName,) where fileIndex is a long, fileSize (in by... | def queryHitReceived(self, descriptorId, ttl, hops, ipAddress, port, resultSet, serventIdentifer, speed): """ Override this to handle query hit messages. @param ipAddress a string representing an IPv4 address like this "140.184.83.37"; This is the representation that the Python Standard Library's socket.connect() expe... |
@param ipAddress a string representing an IPv4 address like this "140.184.83.37"; This is the representation that the Python Standard Library's socket.connect() expects. @param port an integer port number @param serventIdentifier string of length 16 @param fileIndex a long @precondition descriptorId must be a string o... | Precondition: descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId)),) @param ipAddress: a string representing an IPv4 address like this "140.184.83.37"; Thi... | def pushReceived(descriptorId, ttl, hops, ipAddress, port, serventIdentifer, fileIndex): """ Override this to handle push messages. @param ipAddress a string representing an IPv4 address like this "140.184.83.37"; This is the representation that the Python Standard Library's socket.connect() expects. @param port an in... |
@precondition descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId)),) @precondition payload must not be larger than MAXUINT32 bytes.: len(payload) <= MAXUINT... | Precondition: descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId)),) Precondition: payload must not be larger than MAXUINT32 bytes.: len(payload) <= MAXUINT... | def sendDescriptor(self, descriptorId, payloadDescriptor, ttl, payload): """ @precondition descriptorId must be a string of length DESCRIPTORLENGTH.: (type(descriptorId) is types.StringType) and (len(descriptorId) == DESCRIPTORLENGTH): "descriptorId: %s :: %s" % (repr(descriptorId), str(type(descriptorId)),) @precondit... |
@precondition descriptor must be a string of the right length to hold a payload of the encoded length.: len(descriptor) == (struct.unpack(PAYLOADENCODING, descriptor[PAYLOADLENGTHOFFSET:HEADERLENGTH])[0] + HEADERLENGTH): "self: %s, descriptor: %s" % (str(self), repr(descriptor),) | Precondition: descriptor must be a string of the right length to hold a payload of the encoded length.: len(descriptor) == (struct.unpack(PAYLOADENCODING, descriptor[PAYLOADLENGTHOFFSET:HEADERLENGTH])[0] + HEADERLENGTH): "self: %s, descriptor: %s" % (str(self), repr(descriptor),) | def descriptorReceived(self, descriptor): """ A Gnutella descriptor has arrived. |
@precondition We must be expecting a GNUTELLA CONNECT handshake move.: (self.initiator and (self.handshake == "initiatorsaidhello")) or ((not self.initiator) and (self.handshake == "start")): "self.initiator: %s, self.handshake: %s, line: %s" % (str(self.initiator), str(self.handshake), str(line),) | Precondition: We must be expecting a GNUTELLA CONNECT handshake move.: (self.initiator and (self.handshake == "initiatorsaidhello")) or ((not self.initiator) and (self.handshake == "start")): "self.initiator: %s, self.handshake: %s, line: %s" % (str(self.initiator), str(self.handshake), str(line),) | def lineReceived(self, line): """ @precondition We must be expecting a GNUTELLA CONNECT handshake move.: (self.initiator and (self.handshake == "initiatorsaidhello")) or ((not self.initiator) and (self.handshake == "start")): "self.initiator: %s, self.handshake: %s, line: %s" % (str(self.initiator), str(self.handshake)... |
_host = socket.gethostbyaddr(socket.gethostname())[0] | def __repr__(self): return '<%s %s %s>'% (self.method, self.uri, self.clientproto) | |
return self._host | return socket.gethostbyaddr(self.transport.getHost()[1]) | def getHost(self): return self._host |
netResult.addCallbacks(self._sendAnswer, self._sendError, | netResult.addCallbacks(self._sendAnswer, self._sendFormattedFailure, | def _recvMessage(self, findObjMethod, requestID, objectID, message, answerRequired, netArgs, netKw): """Received a message-send. |
callbackArgs=(d, client, service, password, perspectiveName or userName)) | callbackArgs=(d, client, service, password, perspectiveName or username)) | def logIn(authServRef, client, service, username, password, perspectiveName=None): """I return a Deferred which will be called back with a Perspective. """ d = defer.Deferred() authServRef.username(username).addCallbacks(_cbLogInRespond, d.armAndErrback, callbackArgs=(d, client, service, password, perspectiveName or us... |
def appendChild(self, child): self.childNodes.append(child) | def appendChild(self, child): # should we be checking the type of the child? self.childNodes.append(child) | |
for r in ans: | for r in answers: | def extractRecord(resolver, name, answers, level = 10): if not level: return None for r in ans: if r.name == name and r.type == dns.A6: return socket.inet_ntop(socket.AF_INET6, r.payload.address) for r in ans: if r.name == name and r.type == dns.AAAA: return socket.inet_ntop(socket.AF_INET6, r.payload.address) for r in... |
class CMulticastPort(cudp.UDPPortMixin, udp.MulticastPort): | class CMulticastPort(cudp.UDPPortMixin, _origMulticastPort): | def _bindSocket(self): _origUDPPort._bindSocket(self) cudp.UDPPortMixin.__init__(self, self) |
udp.MulticastPort.__init__(self, *args, **kwargs) | _origMulticastPort.__init__(self, *args, **kwargs) def _bindSocket(self): _origMulticastPort._bindSocket(self) | def __init__(self, *args, **kwargs): udp.MulticastPort.__init__(self, *args, **kwargs) cudp.UDPPortMixin.__init__(self, self) |
self._setRealAddress(self.addr[1]) | self._setRealAddress(self.addr[0]) | def resolveAddress(self): if abstract.isIPAddress(self.addr[0]): self._setRealAddress(self.addr[1]) else: main.resolver.resolve(self.addr[0], self._setRealAddress, self.failIfNotConnected) |
str = u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"><head><title>Divmod Quotient</title><link href="/css" rel="stylesheet" /></head><body><img src="/images/anonymous-logo.png" id="anonym... | def testNamedChildren(self): tests = {"<foo><bar /><bar unf='1' /><bar>asdfadsf</bar>" "<bam/></foo>" : 3, '<foo>asdf</foo>' : 0, '<foo><bar><bar></bar></bar></foo>' : 1, } for t in tests.keys(): node = microdom.parseString(t).documentElement result = domhelpers.namedChildren(node, 'bar') self.assertEquals(len(result),... | |
otherwise it returns "name" | otherwise it returns "<string>" | def _getFPName(fp): """returns a file object's name attr if it has one, otherwise it returns "name" """ if hasattr(fp, 'name'): return fp.name return 'file' # stringIO objects have no .name attr |
return 'file' | return getattr(fp, 'name', '<string>') | def _getFPName(fp): """returns a file object's name attr if it has one, otherwise it returns "name" """ if hasattr(fp, 'name'): return fp.name return 'file' # stringIO objects have no .name attr |
def __init__(self): self.portal = None self.shell = None self.user = None self.peerHost = None self.dtpTxfrMode = None self.blocked = None self.dtpFactory = None self.dtpInstance = None self.dtpPort = None self.dtpInetPort = None self.dtpHostPort = None self.binary = True | portal = None shell = None user = None peerHost = None dtpTxfrMode = None blocked = None dtpFactory = None dtpInstance = None dtpPort = None dtpInetPort = None dtpHostPort = None binary = True | def cleanPath(path): # cleanup backslashes and multiple foreslashes log.debug("pre-cleaned path: %s" % path) if path: path = re.sub(r'[\\]{2,}?', '/', path) path = re.sub(r'[/]{2,}?','/', path) path = re.sub(r'[*]?', '', path) path = os.path.normpath(path) log.debug('cleaned path: %s' % path) return path |
print 'YAY' | def _cbLogin(self, (i, a, l), message, host, port): print 'YAY' # It's stateless, matey. What a joke. self.register(message, host, port) | |
log.debug('DTPFacotry.buildProtocol') | log.debug('DTPFactory.buildProtocol') | def buildProtocol(self, addr): log.debug('DTPFacotry.buildProtocol') self.cancelTimeout() if self.pi.dtpInstance: # only create one instance return p = DTP() p.factory = self p.pi = self.pi self.pi.dtpInstance = p return p |
def doStop(self): log.debug('dtpFactory.doStop') if self.numPorts > 0: protocol.Factory.doStop(self) | def stopFactory(self): log.debug('dtpFactory.stopFactory') | def doStop(self): log.debug('dtpFactory.doStop') if self.numPorts > 0: protocol.Factory.doStop(self) self.cancelTimeout() |
self.doStop() | self.stopFactory() | def timeoutFactory(self): log.msg('timed out waiting for DTP connection') if self.deferred: d, self.deferred = self.deferred, None d.errback(defer.TimeoutError()) self.doStop() |
if self.dtpFactory.deferred: d, self.dtpFactory.deferred = self.dtpFactory.deferred, None d.errback(FTPTimeoutError('cleaning up dtp!')) | def timeoutConnection(self): log.msg('FTP timed out') self.transport.loseConnection() if self.dtpFactory.deferred: d, self.dtpFactory.deferred = self.dtpFactory.deferred, None d.errback(FTPTimeoutError('cleaning up dtp!')) | |
self.setTimeout(self.timeOut) log.err(error) | log.msg(error) self.setTimeout(self.factory.timeOut) | def _ebDTP(self, error): self.setTimeout(self.timeOut) # restart timeOut clock after DTP returns log.err(error) r = error.trap(defer.TimeoutError, # this is called when DTP times out BogusClientError, # called if PI & DTP clients don't match FTPTimeoutError, # called when F... |
self.dtpFactory.doStop() | self.dtpFactory.stopFactory() | def cleanupDTP(self): """call when DTP connection exits """ log.debug('cleanupDTP') |
d.addCallback(lambda _: self.setTimeout(self.timeOut)) | d.addCallback(lambda _: self.setTimeout(self.factory.timeOut)) | def _doDTPCommand(self, cmd, *arg): self.setTimeout(None) # don't Time out when waiting for DTP Connection log.debug('FTP._doDTPCommand: self.blocked: %s' % self.blocked) if self.blocked is None: self.blocked = [] try: f = getattr(self.dtpInstance, "dtp_%s" % cmd, None) log.debug('running dtp function %s'... |
@ivar timeOut: the protocol interpreter's idle timeout time in seconds | @ivar timeOut: the protocol interpreter's idle timeout time in seconds, default is 600 seconds | def ftp_QUIT(self, params=''): self.transport.loseConnection() log.debug("Client Quit") |
def getUnixLongListString(self, path): | def getUnixLongListString(self, spath): | def getUnixLongListString(self, path): """generates the equivalent output of a unix ls -l path, but using python-native code. |
cpath, spath = self.mapCPathToSPath(path) log.debug('cpath: %s, spath:%s' % (cpath, spath)) | def getUnixLongListString(self, path): """generates the equivalent output of a unix ls -l path, but using python-native code. | |
sio = self.getUnixLongListString(path) | cpath, spath = self.mapCPathToSPath(path) log.debug('cpath: %s, spath:%s' % (cpath, spath)) sio = self.getUnixLongListString(spath) | def list(self, path): sio = self.getUnixLongListString(path) return (sio, len(sio.getvalue())) |
def setUp(self): base.DelayedCall.debug = True | def stopFactory(self): if hasattr(self, "logFile"): if self.logFile != log.logfile: self.logFile.close() del self.logFile | |
poidl = re.compile(r'"((?:\\"|.)*?)"(?: (<.*?>))?') | poidl = re.compile(r'(?:"((?:\"|.)*?)" |)<([^>]*)>') | def writeHeader(f, k, v): f.write(k.replace("\\", "\\\\").replace("\n", "\\n").replace(": ", ":\ ")) f.write(": ") f.write(v.replace("\n", "\n\t")) f.write("\n") |
oid = oidx[1:-1] | def loadOIDList(self, s): l = [] for descript, oidx in parseOIDList(s): oid = oidx[1:-1] l.append(self.loadNow(oid)) return l | |
Integer.__init__(self, name, allowNone=1, default=default, shortDesc=shortDesc, | Integer.__init__(self, name, allowNone=allowNone, default=default, shortDesc=shortDesc, | def __init__(self, name, min, max, allowNone=1, default=None, shortDesc=None, longDesc=None, hints=None): self.min = min self.max = max Integer.__init__(self, name, allowNone=1, default=default, shortDesc=shortDesc, longDesc=longDesc, hints=hints) |
return ('UNIX', self.socket.getsockname()) | return ('UNIX', repr(self.socket.getsockname())) | def getHost(self): return ('UNIX', self.socket.getsockname()) |
return ('UNIX', self.hostname) | return ('UNIX', repr(self.hostname)) | def getPeer(self): return ('UNIX', self.hostname) |
log.msg("%s starting on %r" % (self.factory.__class__, self.port)) | log.msg("%s starting on %r" % (self.factory.__class__, repr(self.port))) | def startListening(self): """Create and bind my socket, and begin listening on it. |
os.chmod(self.port, self.mode) | try: os.chmod(self.port, self.mode) except: pass | def startListening(self): """Create and bind my socket, and begin listening on it. |
return ('UNIX', self.socket.getsockname()) | return ('UNIX', repr(self.socket.getsockname())) | def getHost(self): """Returns a tuple of ('UNIX', fileName) |
return ('UNIX', self.addr) | return ('UNIX', repr(self.addr)) | def getPeer(self): return ('UNIX', self.addr) |
log.msg("%s starting on %s"%(self.protocol.__class__, self.port)) | log.msg("%s starting on %s"%(self.protocol.__class__, repr(self.port))) | def _bindSocket(self): log.msg("%s starting on %s"%(self.protocol.__class__, self.port)) try: skt = self.createInternetSocket() # XXX: haha misnamed method if self.port: skt.bind(self.port) except socket.error, le: raise error.CannotListenError, (None, self.port, le) if self.port: os.chmod(self.port, self.mode) self.co... |
os.chmod(self.port, self.mode) | try: os.chmod(self.port, self.mode) except: pass | def _bindSocket(self): log.msg("%s starting on %s"%(self.protocol.__class__, self.port)) try: skt = self.createInternetSocket() # XXX: haha misnamed method if self.port: skt.bind(self.port) except socket.error, le: raise error.CannotListenError, (None, self.port, le) if self.port: os.chmod(self.port, self.mode) self.co... |
return ('UNIX_DGRAM',)+self.socket.getsockname() | return ('UNIX_DGRAM',repr(self.socket.getsockname())) | def getHost(self): """ Returns a tuple of ('UNIX_DGRAM', address), indicating the servers address """ return ('UNIX_DGRAM',)+self.socket.getsockname() |
if (no == ECONNREFUSED) or (platformType == "win32" and no == WSAECONNRESET): | if no == ECONNREFUSED: | def doRead(self): """Called when my socket is ready for reading.""" read = 0 while read < self.maxThroughput: try: data, addr = self.socket.recvfrom(self.maxPacketSize) read += len(data) self.protocol.datagramReceived(data) except socket.error, se: no = se.args[0] if no in (EAGAIN, EINTR, EWOULDBLOCK): return if (no ==... |
def __init__(self, directory, smartHostIP, maxConnections=1, | def __init__(self, directory, smartHostAddr, maxConnections=1, | def __init__(self, directory, smartHostIP, maxConnections=1, maxMessagesPerConnection=10): '''initialize |
self.smartHostIP = smartHostIP self.delayed = delayed | self.smartHostAddr = smartHostAddr | def __init__(self, directory, smartHostIP, maxConnections=1, maxMessagesPerConnection=10): '''initialize |
notifyFailure = notifySuccess | def notifyFailure(self, relay, message): log.log("could not relay "+message) self.notifySuccess(relay, message) | def notifySuccess(self, relay, message): '''a relay sent a message successfully |
transport = tcp.Client(smartHostIP, 25, protocol) | transport = tcp.Client(smartHostAddr[0], smartHostAddr[1], protocol) | def checkState(self): '''call me periodically to check I am still up to date |
raise HTTPError(responsecode.FORBIDDEN, StatusResponse("Protected property %s may not be set." % (property.sname(),))) | raise HTTPError(StatusResponse(responsecode.FORBIDDEN, "Protected property %s may not be set." % (property.sname(),))) | def writeProperty(self, property, request): """ See L{IDAVResource.writeProperty}. """ assert isinstance(property, davxml.WebDAVElement) |
raise HTTPError(responsecode.FORBIDDEN, StatusResponse("Live property %s cannot be deleted." % (property.sname(),))) | raise HTTPError(StatusResponse(responsecode.FORBIDDEN, "Live property %s cannot be deleted." % (property.sname(),))) | def removeProperty(self, property, request): """ See L{IDAVResource.removeProperty}. """ if type(property) is tuple: qname = property else: qname = property.qname() |
print "EXIT", self | pass | def exit(self, request): """We are done handling the node to which this controller was attached. """ print "EXIT", self |
self.assertEquals(c.index, 1000) | self.assertEquals(c.index, 1000, "threads lost a count") | def testCallInThread(self): c = Counter() for i in range(1000): reactor.callInThread(c.sync_add) oldIndex = 0 while c.index < 1000: assert oldIndex <= c.index oldIndex = c.index self.assertEquals(c.index, 1000) |
[(j[0], repr(j[1])) for j in v[3]], [(j[0], repr(j[1])) for j in v[4]] | [(j[0], reflect.safe_repr(j[1])) for j in v[3]], [(j[0], reflect.safe_repr(j[1])) for j in v[4]] | def __getstate__(self): """Avoid pickling objects in the traceback. """ if self.pickled: return self.__dict__ c = self.__dict__.copy() c['frames'] = [ [ v[0], v[1], v[2], [(j[0], repr(j[1])) for j in v[3]], [(j[0], repr(j[1])) for j in v[4]] ] for v in self.frames ] |
def __init__(self, text=None): | def __init__(self, text=None, public=0): | def __init__(self, text=None): self.text = text self.deferred = Deferred() self.ready = 1 |
ftpCommand.deferred.errback(Failure(ConnectionLost('FTP connection lost', error))) | ftpCommand.fail(Failure(ConnectionLost('FTP connection lost', error))) | def fail(self, error): """Disconnect, and also give an error to any queued deferreds.""" self.transport.loseConnection() while self.actionQueue: ftpCommand = self.popCommandQueue() ftpCommand.deferred.errback(Failure(ConnectionLost('FTP connection lost', error))) return error |
self.queueStringCommand(command).addErrback(self.fail) | self.queueStringCommand(command, public=0).addErrback(self.fail) | def queueLogin(self): """Initialise the connection. |
cmd = FTPCommand(command) | def buildProtocol(self, ignored): self.protocol.factory = self return self.protocol | |
def queueStringCommand(self, command): | def queueStringCommand(self, command, public=1): | def queueStringCommand(self, command): """Queues a string to be issued as an FTP command Returns a Deferred that will be called when the response to the command has been received.""" ftpCommand = FTPCommand(command) self.queueCommand(ftpCommand) return ftpCommand.deferred |
ftpCommand = FTPCommand(command) | ftpCommand = FTPCommand(command, public) | def queueStringCommand(self, command): """Queues a string to be issued as an FTP command Returns a Deferred that will be called when the response to the command has been received.""" ftpCommand = FTPCommand(command) self.queueCommand(ftpCommand) return ftpCommand.deferred |
self.factory.connectionDisconnected.callback(None) | self.factory.connectionDisconnected.callback(reason) | def connectionLost(self, reason): self.factory.connectionDisconnected.callback(None) |
class ImmediateDisconnectTestCase(unittest.TestCase, ContextGeneratingMixin): todo = "Logged SSL.Error - [('SSL routines', 'SSL23_READ', 'ssl handshake failure')]" | class ConnectionLostTestCase(unittest.TestCase, ContextGeneratingMixin): | def testOpenSSLBuffering(self): serverProto = self.serverProto = SingleLineServerProtocol() clientProto = self.clientProto = RecordingClientProtocol() |
"""construct all the SQL for database operations on <tableName> and populate the class <rowClass> with that info. | """Construct all the SQL templates for database operations on <tableName> and populate the class <rowClass> with that info. | def _populateSchemaFor(self, rc): """construct all the SQL for database operations on <tableName> and populate the class <rowClass> with that info. """ attributes = ("rowColumns", "rowKeyColumns", "rowTableName" ) for att in attributes: if not hasattr(rc, att): raise DBError("RowClass %s must have class variable: %s" %... |
"""(Internal) Build SQL to update a RowObject. | """(Internal) Build SQL template to update a RowObject. | def buildUpdateSQL(self, tableInfo): """(Internal) Build SQL to update a RowObject. |
"""(Internal) Build SQL to insert a new row. | """(Internal) Build SQL template to insert a new row. | def buildInsertSQL(self, tableInfo): """(Internal) Build SQL to insert a new row. |
"""Build the SQL to delete a row from the table. | """Build the SQL template to delete a row from the table. | def buildDeleteSQL(self, tableInfo): """Build the SQL to delete a row from the table. """ sql = "DELETE FROM %s " % tableInfo.rowTableName # build where clause first = 1 sql = sql + " WHERE " for keyColumn, type in tableInfo.rowKeyColumns: if not first: sql = sql + " AND " sql = sql + " %s = %s " % (keyColumn, "%s") fi... |
"""build SQL to update my current state. | """Build SQL to update the contents of rowObject. | def updateRowSQL(self, rowObject): """build SQL to update my current state. """ args = [] tableInfo = self.schema[rowObject.rowTableName] # build update attributes for column, type in tableInfo.rowColumns: if not getKeyColumn(rowObject.__class__, column): args.append(self.quote_value(rowObject.findAttribute(column), ty... |
"""update my contents to the database. | """Update the contents of rowObject to the database. | def updateRow(self, rowObject): """update my contents to the database. """ sql = self.updateRowSQL(rowObject) rowObject.setDirty(0) return self.runOperation(sql) |
"""build SQL to insert my current state. | """Build SQL to insert the contents of rowObject. | def insertRowSQL(self, rowObject): """build SQL to insert my current state. """ args = [] tableInfo = self.schema[rowObject.rowTableName] # build values for column, type in tableInfo.rowColumns: args.append(self.quote_value(rowObject.findAttribute(column), type)) return self.getTableInfo(rowObject).insertSQL % tuple(ar... |
"""insert a new row for this object instance. | """Insert a new row for rowObject. | def insertRow(self, rowObject): """insert a new row for this object instance. """ rowObject.setDirty(0) sql = self.insertRowSQL(rowObject) return self.runOperation(sql) |
"""build SQL to delete me from the db. | """Build SQL to delete rowObject from the database. | def deleteRowSQL(self, rowObject): """build SQL to delete me from the db. """ args = [] tableInfo = self.schema[rowObject.rowTableName] # build where clause for keyColumn, type in tableInfo.rowKeyColumns: args.append(self.quote_value(rowObject.findAttribute(keyColumn), type)) |
suite.run(reporter) sys.exit(not reporter.allPassed()) | if config['debug']: import pdb pdb.run("suite.run(reporter)", globals(), locals()) else: suite.run(reporter) sys.exit(not reporter.allPassed()) | def run(): if len(sys.argv) == 1: sys.argv.append("--help") config = Options() try: config.parseOptions() except usage.error, ue: print "%s: %s" % (sys.argv[0], ue) os._exit(1) if config['reactor']: from twisted.python import reflect mod = 'twisted.internet.' + config['reactor'] print "Using %s reactor" % mod reflect... |
def sendLine(self, line): basic.LineReceiver.sendLine(self, line) | def sendLine(self, line): basic.LineReceiver.sendLine(self, line) | |
def gotHead(self, error): | def getHeadFailed(self, error): | def gotHead(self, error): "Override for notification when fetchHead() action fails" |
log.msg('%s: fetchGroups()' % self.ip) | def fetchGroups(self): log.msg('%s: fetchGroups()' % self.ip) self.sendLine('LIST') self._newState(self._stateList, self.getAllGroupsFailed) | |
log.msg('%s: fetchOverview()' % self.ip) | def fetchOverview(self): log.msg('%s: fetchOverview()' % self.ip) self.sendLine('LIST OVERVIEW.FMT') self._newState(self._stateOverview, self.getOverviewFailed) | |
log.msg('%s: fetchSubscriptions()' % self.ip) | def fetchSubscriptions(self): log.msg('%s: fetchSubscriptions()' % self.ip) self.sendLine('LIST SUBSCRIPTIONS') self._newState(self._stateSubscriptions, self.getSubscriptionsFailed) | |
log.msg('%s: fetchGroup()' % self.ip) self.sendLine('GROUP %s' % group) | self.sendLine('GROUP %s' % (group,)) | def fetchGroup(self, group): log.msg('%s: fetchGroup()' % self.ip) self.sendLine('GROUP %s' % group) self._newState(None, self.getGroupFailed, self._headerGroup) |
def fetchHead(self, index): log.msg('%s: fetchHead(%s)' % (self.ip, index)) self.sendLine('HEAD %d' % index) | def fetchHead(self, index = ''): """fetchHead(self, index = '') Get the header for the specified article (or the currently selected article if index is '') from the server. gotHead() is called on success, getHeadFailed() on failure """ self.sendLine('HEAD %s' % (index,)) | def fetchHead(self, index): log.msg('%s: fetchHead(%s)' % (self.ip, index)) self.sendLine('HEAD %d' % index) self._newState(self._stateHead, self.getHeadFailed) |
def fetchBody(self, index): log.msg('%s: fetchBody(%s)' % (self.ip, index)) self.sendLine('BODY %d' % index) | def fetchBody(self, index = ''): """fetchBody(self, index = '') Get the body for the specified article (or the currently selected article if index is '') from the server. gotBody() is called on success, getBodyFailed() on failure """ self.sendLine('BODY %s' % (index,)) | def fetchBody(self, index): log.msg('%s: fetchBody(%s)' % (self.ip, index)) self.sendLine('BODY %d' % index) self._newState(self._stateBody, self.getBodyFailed) |
def fetchArticle(self, index): log.msg('%s: fetchArticle(%s)' % (self.ip, index)) self.sendLine('ARTICLE %d' % index) | def fetchArticle(self, index = ''): """fetchArticle(self, index = '') Get the complete article with the specified index (or the currently selected article if index is '') from the server. gotArticle() is called on success, getArticleFailed() on failure """ self.sendLine('ARTICLE %s' % (index,)) | def fetchArticle(self, index): log.msg('%s: fetchArticle(%s)' % (self.ip, index)) self.sendLine('ARTICLE %d' % index) self._newState(self._stateArticle, self.getArticleFailed) |
log.msg('%s: postArticle()') | def postArticle(self, text): log.msg('%s: postArticle()') self.sendLine('POST') self._newState(None, self.postFailed, self._headerPost) self._postText = text | |
self._postText = text | self._postText.append(text) | def postArticle(self, text): log.msg('%s: postArticle()') self.sendLine('POST') self._newState(None, self.postFailed, self._headerPost) self._postText = text |
log.msg('%s: fetchXHeader()') if message is not None: | if id is not None: | def fetchXHeader(self, header, low = None, high = None, id = None): log.msg('%s: fetchXHeader()') if message is not None: r = header + ' <%s>' % (id,) elif low is high is None: r = header elif high is None: r = header + ' %d-' % (low,) elif low is None: r = header + ' -%d' % (high,) else: r = header + ' %d-%d' % (low, ... |
self.transport.write(self._postText) | self.transport.write(self._postText[0]) | def _headerPost(self, (code, message)): if code == 340: self.transport.write(self._postText) if self._postText[-2:] != '\r\n': self.sendLine('\r\n') self.sendLine('.') self._newState(None, self.postFailed, self._headerPosted) else: self.postFailed(line) self._endState() |
self.queueStringCommand(command, public=0).addErrback(self.fail) | d = self.queueStringCommand(command, public=0) d.addErrback(self.fail) d.addErrback(lambda x: None) | def queueLogin(self): """Initialise the connection. |
return self.runOperation(self.schema, self.schemaCreated, self.schemaNotCreated) | return self.runOperation(self.schema).addCallbacks(self.schemaCreated, self.schemaNotCreated) | def createSchema(self): return self.runOperation(self.schema, self.schemaCreated, self.schemaNotCreated) |
return gtk.input_add(source.fileno(), condition, wrapper) | return gtk._gobject.io_add_watch(source.fileno(), condition, wrapper) | def wrapper(source, condition, real_s=source, real_cb=callback): return real_cb(real_s, condition) |
return gtk.input_add(source, condition, callback) | return gtk._gobject.io_add_watch(source, condition, callback) | def wrapper(source, condition, real_s=source, real_cb=callback): return real_cb(real_s, condition) |
reads[reader] = self.input_add(reader, gtk.gdk.INPUT_READ, self.callback) | reads[reader] = self.input_add(reader, INFLAGS, self.callback) | def addReader(self, reader): if not hasReader(reader): reads[reader] = self.input_add(reader, gtk.gdk.INPUT_READ, self.callback) self.simulate() |
writes[writer] = self.input_add(writer, gtk.gdk.INPUT_WRITE, self.callback) | writes[writer] = self.input_add(writer, OUTFLAGS, self.callback) | def addWriter(self, writer): if not hasWriter(writer): writes[writer] = self.input_add(writer, gtk.gdk.INPUT_WRITE, self.callback) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.