rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return call_until_failure(_doRun, config) | return _getDebugger(config).runcall(call_until_failure, _doRun, config) | def _doRun(config): suite = _getSuite(config) _getDebugger().run("suite.run(config['random'])", globals(), locals()) return suite |
File._directoryLister = DirectoryLister | def __repr__(self): return '<DirectoryLister of %r>' % self.path | |
return defer.deferToThread(socket.gethostbyname, name).chainDeferred(d) | return threads.deferToThread(socket.gethostbyname, name) | def getHostByName(self, name, timeout = 10): # XXX - Make this respect timeout return defer.deferToThread(socket.gethostbyname, name).chainDeferred(d) |
rw = 1 | def testIdListParser(self): inputs = [ '1', '1,2', '1,3,5', '1:10', '1:10,11', '1:5,10:20', '1,5:10', '1,5:10,15:20', '1:10,15,20:25', ] outputs = [ [1], [1, 2], [1, 3, 5], range(1, 11), range(1, 12), range(1, 6) + range(10, 21), [1] + range(5, 11), [1] + range(5, 11) + range(15, 21), range(1, 11) + [15] + range(20, 2... | |
return 1 | return self.rw | def isWriteable(self): return 1 |
self._cbStopClient() | self._cbStopClient(None) | def examined(args): self.examinedArgs = args self._cbStopClient() |
testExamine.todo = "Test framework's mailbox is always READ-WRITE" | def examined(args): self.examinedArgs = args self._cbStopClient() | |
pwrq.addCallback(self._testmakeIdentity_1) pwrq.addErrback(self._testmakeIdentity_1fail) | pwrq.addCallbacks(self._testmakeIdentity_1, self._testmakeIdentity_1fail) | def testmakeIdentity(self): self.ident = ident = self.perspective.makeIdentity("password") # simple password verification pwrq = ident.verifyPlainPassword("password") pwrq.addCallback(self._testmakeIdentity_1) pwrq.addErrback(self._testmakeIdentity_1fail) pwrq.arm() |
self.fail("Identity did not verify with plain password") | try: self.fail("Identity did not verify with plain password: %s" % msg) except self.failureException, e: self.error = sys.exc_info() raise | def _testmakeIdentity_1fail(self, msg): self.fail("Identity did not verify with plain password") |
self.fail("Identity did not verify with hashed password") | try: self.fail("Identity did not verify with hashed password: %s" % msg) except self.failureException, e: self.error = sys.exc_info() raise | def _testmakeIdentity_2fail(self, msg): self.fail("Identity did not verify with hashed password") |
log.msg('Removing stale pidfile %s' % pidfile) | log.msg('Removing stale pidfile %s' % pidfile, isError=True) | def checkPID(pidfile): if os.path.exists(pidfile): try: pid = int(open(pidfile).read()) except ValueError: sys.exit('Pidfile %s contains non-numeric value' % pidfile) try: os.kill(pid, 0) except OSError, why: if why[0] == errno.ESRCH: # The pid doesnt exists. log.msg('Removing stale pidfile %s' % pidfile) os.remove(pid... |
checkPID(config['pidfile']) | def runApp(config): passphrase = app.getPassphrase(config['encrypted']) app.installReactor(config['reactor']) config['nodaemon'] = config['nodaemon'] or config['debug'] oldstdout = sys.stdout oldstderr = sys.stderr startLogging(config['logfile'], config['syslog'], config['prefix'], config['nodaemon']) app.initialLog() ... | |
for tag, value, desc in arg.choices: | for tag, value, desc in arg.flags: | def input_checkgroup(self, request, content, arg): s = content.div() defaults = getValues(request, arg) for tag, value, desc in arg.choices: if value in defaults: kw = {'checked' : '1'} else: kw = {} s.input(type="checkbox", name=arg.name, value=tag, **kw).text(desc) return s |
log.msg('other side refused open\nreason: %s'%(self.id, reason)) | log.msg('other side refused open\nreason: %s'% reason) | def openFailed(self, reason): """ Called when the the open failed for some reason. reason.desc is a string descrption, reason.code the the SSH error code. |
factory.protocol = wire.Echo | factory.protocol = TestEcho TestEcho.d = defer.Deferred() | def testUNIX(self): if not interfaces.IReactorUNIX(reactor, None): raise unittest.SkipTest, "This reactor does not support UNIX domain sockets" s = service.MultiService() c = compat.IOldApplication(s) factory = protocol.ServerFactory() factory.protocol = wire.Echo if os.path.exists('.hello.skt'): os.remove('hello.skt')... |
s.stopService() | util.wait(defer.maybeDeferred(s.stopService)) | def lineReceived(self, line): self.factory.line = line |
factory.protocol = wire.Echo | factory.protocol = TestEcho TestEcho.d = defer.Deferred() | def testTCP(self): s = service.MultiService() c = compat.IOldApplication(s) factory = protocol.ServerFactory() factory.protocol = wire.Echo c.listenTCP(0, factory) s.privilegedStartService() s.startService() num = list(s)[0]._port.getHost().port class Foo(basic.LineReceiver): def connectionMade(self): self.transport.wr... |
entry.insert_text(result[0]) entry.set_position(oldpos+len(result[0])-len(word)) | entry.insert_defaults(result[0]) entry.set_position(oldpos+len(result[0])-len(word)-1) | def handle_key_press_event(self, entry, event): stopSignal = False # ASSUMPTION: Assume Meta == mod4 isMeta = event.state & gtk.GDK.MOD4_MASK |
except Exception, (e,): log.err() | except Exception, e: log.err(e) | def lineReceived(self, line): "Process the input from the client" self.resetTimeout() line = string.strip(line) log.debug(repr(line)) line = self.reTelnetChars.sub('', line) # clean up '\xff\xf4\xff' nonsense line = line.encode() try: cmdAndArgs = line.split(' ',1) log.debug('processing command %s' % cmdAndArgs) self.... |
if self.fp is not None: | if self.fp is not None and not self.fp.closed: | def finishedFileTransfer(self, *arg): """called back when a file transfer has been completed by the dtp""" log.debug('finishedFileTransfer! cleaning up DTP') if self.fp is not None: if self.fp.tell() == self.fpsize: log.debug('transfer completed okay :-)') self.reply(TXFR_COMPLETE_OK) else: log.debug("uh-oh there was a... |
if self.tld is not None: self.filepath = python.FilePath(self.tld) | def __init__(self, user=None, tld=None): """Constructor @param user: the name of the user whose permissions we'll be using @type user: string """ self.user = user # user name self.tld = tld self.debug = True | |
except OSError, (e,): | except (IOError, OSError), (e,): | def retr(self, path): import os.path as osp cpath, spath = self.mapCPathToSPath(path) if not osp.isfile(spath): raise FileNotFoundError(cpath) try: return (file(spath, 'rb'), os.path.getsize(spath)) except OSError, (e,): log.debug(e) raise OperationFailedError('') |
raise OperationFailedError('') | raise OperationFailedError('An OSError occurred %s' % e) | def retr(self, path): import os.path as osp cpath, spath = self.mapCPathToSPath(path) if not osp.isfile(spath): raise FileNotFoundError(cpath) try: return (file(spath, 'rb'), os.path.getsize(spath)) except OSError, (e,): log.debug(e) raise OperationFailedError('') |
def resetMode(self, moeds): | def resetMode(self, modes): | def resetMode(self, moeds): pass |
@param inedx: The number of the message for which to retrieve the size, | @param index: The number of the message for which to retrieve the size, | def listMessages(self, index=None): """Retrieve the size of one or more messages. @type index: C{int} or C{None} @param inedx: The number of the message for which to retrieve the size, or None to retrieve the size of all messages. @rtype: C{int} or any iterable of C{int} @return: The number of octets in the specified... |
for url in ['/foo/', '/foo/bar', '/foo/bar/baz', 'foo/bar/']: | for url in ['/foo/', '/foo/bar', '/foo/bar/baz', '/foo/bar/']: | def testSimple(self): for url in ['/foo/', '/foo/bar', '/foo/bar/baz', 'foo/bar/']: request = server.Request(self.d, 1) request.setHost('example.com', 81) request.gotLength(0) request.requestReceived('GET', '/foo/bar/baz', 'HTTP/1.0') self.assertEqual(request.getRootURL(), "http://example.com/foo") |
request.requestReceived('GET', '/foo/bar/baz', 'HTTP/1.0') | request.requestReceived('GET', url, 'HTTP/1.0') | def testSimple(self): for url in ['/foo/', '/foo/bar', '/foo/bar/baz', 'foo/bar/']: request = server.Request(self.d, 1) request.setHost('example.com', 81) request.gotLength(0) request.requestReceived('GET', '/foo/bar/baz', 'HTTP/1.0') self.assertEqual(request.getRootURL(), "http://example.com/foo") |
return self.name.lower() == other.name.lower() | return str(self.name).lower() == str(other.name).lower() | def __eq__(self, other): if isinstance(other, SimpleRecord): return self.name.lower() == other.name.lower() return 0 |
log.msg(repr(ord(packet[0]))) log.msg(repr(hasattr(self, 'first'))) log.msg(repr(len(self.buf))) | def dataReceived(self, data): self.buf = self.buf+data if not self.gotVersion: parts = self.buf.split('\n') for p in parts: if p[: 4] == 'SSH-': self.gotVersion = 1 self.otherVersionString = p.strip() if p.split('-')[1]not in('1.99', '2.0'): # bad version self.sendDisconnect(DISCONNECT_PROTOCOL_VERSION_NOT_SUPPORTED, '... | |
x = StringIO.StringIO() | x = cStringIO.StringIO() | def listUsers(self, req): import pwd x = StringIO.StringIO() x.write('<UL>\n') for user in pwd.getpwall(): pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell \ = user realname = string.split(pw_gecos,',')[0] if not realname: realname = pw_name fmtStr = '<LI><A HREF="%s/">%s (%s)</a>\n' if os.path.exists(os.... |
compiler.compile(["conftest.c"]) | compiler.compile(["conftest.c"], output_dir='') | def _check_header(self, header_name): """ Check if the given header can be included by trying to compile a file that contains only an #include line. """ compiler = new_compiler() compiler.announce("checking for %s ..." % header_name, 0) |
gtk.GtkWindow(self, gtk.WINDOW_TOPLEVEL) | gtk.GtkWindow.__init__(self, gtk.WINDOW_TOPLEVEL) | def __init__(self): gtk.GtkWindow(self, gtk.WINDOW_TOPLEVEL) |
def __call__(self, adaptable, default=_Nothing, persist=None, registry=None): if registry != None: raise RuntimeError, "registry argument will be ignored" if persist != None: warnings.warn("persist argument is deprecated", DeprecationWarning) if default == _Nothing: default = self.marker return interface.InterfaceClas... | def __call__(): def __call__(self, adaptable, default=_Nothing, persist=None, registry=None): if registry != None: raise RuntimeError, "registry argument will be ignored" if persist != None: warnings.warn("persist argument is deprecated", DeprecationWarning) if default == _Nothing: default = self.marker if hasattr(a... | def __call__(self, adaptable, default=_Nothing, persist=None, registry=None): if registry != None: raise RuntimeError, "registry argument will be ignored" # possibly should be removed for efficiency reasons if persist != None: warnings.warn("persist argument is deprecated", DeprecationWarning) if default == _Nothing: d... |
registry.register([self], [to], '', using) | registry.registerAdapter(using, self, to) | def adaptWith(self, using, to, registry=None): if registry != None: raise RuntimeError, "registry argument will be ignored" warnings.warn("persist argument is deprecated", DeprecationWarning) registry = theAdapterRegistry registry.register([self], [to], '', using) |
self.register([origInterface], interfaceClasses, '', adapterFactory) | def registerAdapter(self, adapterFactory, origInterface, *interfaceClasses): """Register an adapter class. | |
return self.adapterRegistry.get((fromInterface, toInterface), default) | raise NotImplementedError | def getAdapterFactory(self, fromInterface, toInterface, default): """Return registered adapter for a given class and interface. """ return self.adapterRegistry.get((fromInterface, toInterface), default) |
if implements(obj, interfaceClass): return obj if persist != False: pkey = (id(obj), interfaceClass) if self.adapterPersistence.has_key(pkey): return self.adapterPersistence[pkey] if hasattr(obj, '__class__'): klas = obj.__class__ else: klas = type(obj) for fromInterface in classToInterfaces(klas): adapterFactory = (... | def getAdapter(self, obj, interfaceClass, default=_Nothing, adapterClassLocator=None, persist=None): """Return an object that implements the given interface. | |
def matcher(element, classes=classes): | def matcher(element, self=self): | def matcher(element, classes=classes): if element.tagName != 'code': return 0 if not element.hasAttribute('class'): return 0 if element.getAttribute('class') in classes: return 0 return 1 |
if element.getAttribute('class') in classes: | if self.allowedCodeClasses(element.getAttribute('class')): | def matcher(element, classes=classes): if element.tagName != 'code': return 0 if not element.hasAttribute('class'): return 0 if element.getAttribute('class') in classes: return 0 return 1 |
if failure.check(IOError): | if failure.check(IOError, OSError): | def msg(err): if what is not None: log.msg("%s while %s" % (err, what)) |
if e == errno.EACCES: | if e == errno.EACCES or e == errno.EPERM: | def msg(err): if what is not None: log.msg("%s while %s" % (err, what)) |
return RSA.construct(decodedKey[1: 6]) | n,e,d,p,q=decodedKey[1:6] return RSA.construct((n,e,d,p,q)) | def getPrivateKeyObject_openssh(data, passphrase): kind = data[0][11: 14] if data[1].startswith('Proc-Type: 4,ENCRYPTED'): # encrypted key ivdata = data[2].split(',')[1][:-1] iv = ''.join([chr(int(ivdata[i:i+2],16)) for i in range(0, len(ivdata), 2)]) if not passphrase: raise BadKeyError, 'encrypted key with no passphr... |
['p', common.MP(obj.p)[4:]], ['q', common.MP(obj.q)[4:]], ['a', common.MP(obj.d%(obj.p-1))[4:]], ['b', common.MP(obj.d%(obj.q-1))[4:]], ['c', common.MP(Util.number.inverse(obj.q, obj.p))[4:]]]]]) | ['p', common.MP(q)[4:]], ['q', common.MP(p)[4:]], ['a', common.MP(obj.d%(q-1))[4:]], ['b', common.MP(obj.d%(p-1))[4:]], ['c', common.MP(Util.number.inverse(p, q))[4:]]]]]) | def makePrivateKeyString_lsh(obj, passphrase): #assert not passphrase keyType = objectType(obj) if keyType == 'ssh-rsa': return sexpy.pack([['private-key', ['rsa-pkcs1', ['n', common.MP(obj.n)[4:]], ['e', common.MP(obj.e)[4:]], ['d', common.MP(obj.d)[4:]], ['p', common.MP(obj.p)[4:]], ['q', common.MP(obj.q)[4:]], ['a',... |
objData = [0, obj.n, obj.e, obj.d, obj.p, obj.q, obj.d%(obj.p-1), obj.d%(obj.q-1),Util.number.inverse(obj.q, obj.p)] | p,q=obj.p,obj.q if p > q: (p,q) = (q,p) objData = [0, obj.n, obj.e, obj.d, q, p, obj.d%(q-1), obj.d%(p-1),Util.number.inverse(p, q)] | def makePrivateKeyString_openssh(obj, passphrase): keyType = objectType(obj) if keyType == 'ssh-rsa': keyData = '-----BEGIN RSA PRIVATE KEY-----\n' objData = [0, obj.n, obj.e, obj.d, obj.p, obj.q, obj.d%(obj.p-1), obj.d%(obj.q-1),Util.number.inverse(obj.q, obj.p)] elif keyType == 'ssh-dss': keyData = '-----BEGIN DSA PR... |
return keyData | return keyData def makePrivateKeyBlob(obj): keyType = objectType(obj) if keyType == 'ssh-rsa': return common.NS(keyType) + common.MP(obj.n) + common.MP(obj.e) + \ common.MP(obj.d) + common.MP(obj.u) + common.MP(obj.q) + \ common.MP(obj.p) elif keyType == 'ssh-dss': return common.NS(keyType) + common.MP(obj.p) + common... | def makePrivateKeyString_openssh(obj, passphrase): keyType = objectType(obj) if keyType == 'ssh-rsa': keyData = '-----BEGIN RSA PRIVATE KEY-----\n' objData = [0, obj.n, obj.e, obj.d, obj.p, obj.q, obj.d%(obj.p-1), obj.d%(obj.q-1),Util.number.inverse(obj.q, obj.p)] elif keyType == 'ssh-dss': keyData = '-----BEGIN DSA PR... |
view = widgets.Widget(self.model) | view = widgets.Widget(model) | def getSubview(self, request, node, model, viewName): """Get a sub-view from me. """ view = None vm = getattr(self, 'wvfactory_' + viewName, None) if vm is None: vm = getattr(self, 'factory_' + viewName, None) if vm is not None: warnings.warn("factory_ methods are deprecated; please use " "wvfactory_ instead", Deprecat... |
ret.append(msg + '\n') | ret.append(str(msg) + '\n') | def formatError(tm): # would need another adapter for tbformat='emacs' ret = [DOUBLE_SEPARATOR, '%s: %s (%s)\n' % (WORDS[tm.status], tm.name, itrial.IFQClassName(tm.klass))] for msg in tm.skip, itrial.ITodo(tm.todo).msg: if msg is not None: ret.append(msg + '\n') if tm.status not in (SUCCESS, SKIP, UNEXPECTED_SUCCESS... |
of the arguments the semantics. | of the semantics of the arguments. | def service(description, factory): """Return the service corresponding to a description @type description: C{str} @type factory: C{twisted.internet.interfaces.IProtocolFactory} @rtype: C{twisted.application.service.IService} @return: the service corresponding to a description of a reliable virtual circuit server. See... |
of the arguments the semantics. | of the semantics of the arguments. | def listen(description, factory): """Listen on a port corresponding to a description @type description: C{str} @type factory: C{twisted.internet.interfaces.IProtocolFactory} @rtype: C{twisted.internet.interfaces.IListeningPort} @return: the port corresponding to a description of a reliable virtual circuit server. See... |
del self.proc | def connectionLost(self, reason): """I close my process's stderr. """ abstract.FileDescriptor.connectionLost(self, reason) os.close(self.proc.stderr) self.proc.errConnectionLost() del self.proc | |
abstract.FileDescriptor.loseConnection(self) | self.stopReading() self.connectionLost(None) | def closeStdout(self): """Close stdout.""" if not self.lostOutConnection: abstract.FileDescriptor.loseConnection(self) |
cp.deferred.addCallback(lambda ign: cp.startTLS()) cp.deferred.addCallback(lambda ign: cp.quit()) def asserts(ign): | def cbConnected(ignored): log.msg("Connected to server; starting TLS") return cp.startTLS() def cbStartedTLS(ignored): log.msg("Started TLS; disconnecting") return cp.quit() def cbDisconnected(ign): log.msg("Disconnected; asserting correct input received") | def testStartTLS(self): sf = TLSServerFactory() sf.protocol.output = [ ['+OK'], # Server greeting ['+OK', 'STLS', '.'], # CAPA response ['+OK'], # STLS response ['+OK', '.'], # Second CAPA response ['+OK'] # QUIT response ] sf.protocol.context = ServerTLSContext() port = reactor.listenTCP(0, sf) |
cp.deferred.addCallback(asserts) | def asserts(ign): self.assertEquals( sf.input, ['CAPA', 'STLS', 'CAPA', 'QUIT']) | |
return defer.maybeDeferred(port.stopListening).addCallback(lambda ign: result) | def cbShutdown(ignored): log.msg("Shut down server") return result return defer.maybeDeferred(port.stopListening).addCallback(cbShutdown) cp.deferred.addCallback(cbConnected) cp.deferred.addCallback(cbStartedTLS) cp.deferred.addCallback(cbDisconnected) | def cleanup(result): conn.disconnect() return defer.maybeDeferred(port.stopListening).addCallback(lambda ign: result) |
if seenNames.has_key(tmlname): debugInspection('Seen %s already' % tmlname) continue seenNames[tmlname] = 1 if exists(tmlname): result.append(tmlname) debugInspection('Found ' + tmlname) | if isAModule(join((d,plugindir))): seenNames[plugindir] = 1 if exists(tmlname): result.append(tmlname) debugInspection('Found ' + tmlname) else: debugInspection('Failed ' + tmlname) | def getPluginFileList(debugInspection=None, showProgress=None): """Find plugin.tml files in subdirectories of paths in C{sys.path} @type debugInspection: C{None} or a callable taking one argument @param debugInspection: If not None, this is invoked with strings containing debug information about the loading process. ... |
debugInspection('Failed ' + tmlname) | debugInspection('Not a module ' + tmlname) | def getPluginFileList(debugInspection=None, showProgress=None): """Find plugin.tml files in subdirectories of paths in C{sys.path} @type debugInspection: C{None} or a callable taking one argument @param debugInspection: If not None, this is invoked with strings containing debug information about the loading process. ... |
log.msg(str(process.reapProcessHandlers.keys())) | def processEnded(self, reason): log.msg("MAD(ssh): connection lost") log.msg(str(process.reapProcessHandlers.keys())) unittest._inst.assertEquals(reason.value.exitCode, 0, 'exit code was not 0: %s' % reason.value.exitCode) self.buf = self.buf.replace('\r\n', '\n') unittest._inst.assertEquals(self.buf, 'goodbye\n') # g... | |
server = Server() | def testShutdownFromDatagramReceived(self): | |
p = reactor.listenUDP(0, server, interface='127.0.0.1') pr = server.packetReceived = defer.Deferred() | pr = self.server.packetReceived = defer.Deferred() | def testShutdownFromDatagramReceived(self): |
server.transport.connectionLost() | self.server.transport.connectionLost() | def pktRece(ignored): # Simulate reactor.stop() behavior :( server.transport.connectionLost() # Then delay this Deferred chain until the protocol has been # disconnected, as the reactor should do in an error condition # such as we are inducing. This is very much a whitebox test. reactor.callLater(0, finished.callback,... |
server.transport.write('\0' * 64, ('127.0.0.1', server.transport.getHost().port)) | self.server.transport.write('\0' * 64, ('127.0.0.1', self.server.transport.getHost().port)) | def flushErrors(ignored): # We are breaking abstraction and calling private APIs, any # number of horrible errors might occur. As long as the reactor # doesn't hang, this test is satisfied. (There may be room for # another, stricter test.) log.flushErrors() |
return "Directory listing for %s" % request.uri | return "Directory listing for %s" % urllib.unquote(request.uri) | def wmfactory_header(self, request): return "Directory listing for %s" % request.uri |
def getNodeController(self, request, node, model): | def getNodeModel(self, submodel): if submodel: modelGetter = DefaultWidget(self.model) modelGetter.setSubmodel(submodel) model = modelGetter.getData() else: model = None return model def getNodeController(self, request, node, submodel): | def getNodeController(self, request, node, model): controllerName = node.getAttribute('controller') # Look up an InputHandler controllerFactory = DefaultHandler if controllerName: namespaces = [self.controller] for namespace in namespaces: controllerFactory = getattr(namespace, 'factory_' + controllerName, None) if co... |
def getNodeView(self, request, node, model): | def getNodeView(self, request, node, submodel): | def getNodeView(self, request, node, model): view = None viewName = node.getAttribute('view') |
if submodel: modelGetter = DefaultWidget(self.model) modelGetter.setSubmodel(submodel) model = modelGetter.getData() else: model = None controller = self.getNodeController(request, node, model) result = self.getNodeView(request, node, model) | controller = self.getNodeController(request, node, submodel) result = self.getNodeView(request, node, submodel) | def handleNode(self, request, node): if not hasattr(node, 'getAttribute'): # text node? return node id = node.getAttribute('model') submodel_prefix = node.getAttribute("_submodel_prefix") if submodel_prefix and id: submodel = "/".join([submodel_prefix, id]) elif id: submodel = id elif submodel_prefix: submodel = submo... |
d = None | # def stopListening(self, s): | |
if self.debug: log.msg('got a DTP connection %s:%s' % (peer[1],peer[2])) if self.debug: log.msg("DTP ip matches PI ip? %s" % str(peer[1] == self.factory.pi.peerHost[1])) | log.debug('got a DTP connection %s:%s' % (peer[1],peer[2])) | def connectionMade(self): """Will start an transfer, if one is queued up, when the client connects""" peer = self.transport.getPeer() if self.debug: log.msg('got a DTP connection %s:%s' % (peer[1],peer[2])) # make sure someone isn't doing something sneaky if self.debug: log.msg("DTP ip matches PI ip? %s" % str(peer[1] ... |
self.factory._unblock() | d, self.factory.deferred = self.factory.deferred, defer.Deferred() log.debug('firing dtpFactory deferred') d.callback(None) | def connectionMade(self): """Will start an transfer, if one is queued up, when the client connects""" peer = self.transport.getPeer() if self.debug: log.msg('got a DTP connection %s:%s' % (peer[1],peer[2])) # make sure someone isn't doing something sneaky if self.debug: log.msg("DTP ip matches PI ip? %s" % str(peer[1] ... |
if self.debug: print "running self.transport.loseConnection()" self.cleanup() def sendFile(self, fp): '''queues up a file object for sending out over the wire''' | self.factory.stopFactory() def dtp_RETR(self, fp): '''ssnds a file object out the wire''' | def connectionLost(self, reason): log.msg('lost DTP connection %s, oh well!' % reason) # makes sure connection is closed and factory shuts down # when client disconnects if self.debug: print "running self.transport.loseConnection()" self.cleanup() |
if self.debug: log.msg('sendfile sending %s' % filename) | log.debug('sendfile sending %s' % filename) | def sendFile(self, fp): '''queues up a file object for sending out over the wire''' filename = _getFPName(fp) self.fp = fp |
class ActvDTPFactory(protocol.ClientFactory): pass | def sendFile(self, fp): '''queues up a file object for sending out over the wire''' filename = _getFPName(fp) self.fp = fp | |
debug = True | def sendFile(self, fp): '''queues up a file object for sending out over the wire''' filename = _getFPName(fp) self.fp = fp | |
dtpPort = None | def sendFile(self, fp): '''queues up a file object for sending out over the wire''' filename = _getFPName(fp) self.fp = fp | |
blocked = [] deferred = defer.Deferred() | deferred = defer.Deferred() | def sendFile(self, fp): '''queues up a file object for sending out over the wire''' filename = _getFPName(fp) self.fp = fp |
if self.debug: log.msg('PasvDTPFactory.buildProtocol') if self.instance: | if self.instance: | def buildProtocol(self, addr): if self.debug: log.msg('PasvDTPFactory.buildProtocol') if self.instance: return p = protocol.ServerFactory.buildProtocol(self, addr) # like in __init__ of a base-class p.factory = self p.debug = self.debug p.pi = self.pi self.instance = p return p |
p.debug = self.debug | def buildProtocol(self, addr): if self.debug: log.msg('PasvDTPFactory.buildProtocol') if self.instance: return p = protocol.ServerFactory.buildProtocol(self, addr) # like in __init__ of a base-class p.factory = self p.debug = self.debug p.pi = self.pi self.instance = p return p | |
self.instance = p | self.pi.dtpInstance = p | def buildProtocol(self, addr): if self.debug: log.msg('PasvDTPFactory.buildProtocol') if self.instance: return p = protocol.ServerFactory.buildProtocol(self, addr) # like in __init__ of a base-class p.factory = self p.debug = self.debug p.pi = self.pi self.instance = p return p |
def doCommand(self, command, *args): if self.blocked is not None: if self.debug: log.msg('dtp blocking (command=%s, args=%s)'% (command, args)) self.blocked.append((command, args)) return if self.debug: log.msg('dtp running (command=%s, args=%s)'% (command, args)) f = getattr(self.instance, command, None) if f: d = d... | def doCommand(self, command, *args): if self.blocked is not None: if self.debug: log.msg('dtp blocking (command=%s, args=%s)'% (command, args)) self.blocked.append((command, args)) | |
if self.dtpPort.connected: if self.debug: log.msg('self.dtpPort.loseConnection()') self.dtpPort.loseConnection() | def stopFactory(self): if self.dtpPort.connected: if self.debug: log.msg('self.dtpPort.loseConnection()') self.dtpPort.loseConnection() | |
blocked = None deferred = None if MODULE_DEBUG: debug = True ANNOYINGLY_VERBOSE = True TESTING = False DEBUG_AUTO_ANON_LOGIN = True HUMAN_READABLE_PASV_PORT = True else: debug, ANNOYINGLY_VERBOSE, TESTING, DEBUG_AUTO_ANON_LOGIN, HUMAN_READABLE_PASV_PORT = (False,False,False,False,False) | blocked = None | def cleanPath(params): # cleanup backslashes and multiple foreslashes if params: params = re.sub(r'[\\]{2,}?', '/', params) params = re.sub(r'[/]{2,}?','/', params) return params |
if self.debug: log.msg('ftp-pi connectionMade') | log.debug('ftp-pi connectionMade') | def connectionMade(self): if self.debug: log.msg('ftp-pi connectionMade') self.reply(WELCOME_MSG) self.peerHost = self.transport.getPeer() if self.debug and self.DEBUG_AUTO_ANON_LOGIN: lr = self.lineReceived lr('USER anonymous') lr('PASS f@d.com') lr('PASV') lr('LIST') lr('RETR .vim/vimrc') |
if self.debug and self.DEBUG_AUTO_ANON_LOGIN: lr = self.lineReceived lr('USER anonymous') lr('PASS f@d.com') lr('PASV') lr('LIST') lr('RETR .vim/vimrc') | self.__testingautologin() def __testingautologin(self): import warnings; warnings.warn(''' --> DEBUGGING CODE ACTIVE!!! <-- ''') lr = self.lineReceived lr('USER anonymous') lr('PASS f@d.com') lr('PASV') lr('LIST') lr('RETR .vim/vimrc') lr('RETR Session.vim') | def connectionMade(self): if self.debug: log.msg('ftp-pi connectionMade') self.reply(WELCOME_MSG) self.peerHost = self.transport.getPeer() if self.debug and self.DEBUG_AUTO_ANON_LOGIN: lr = self.lineReceived lr('USER anonymous') lr('PASS f@d.com') lr('PASV') lr('LIST') lr('RETR .vim/vimrc') |
if self.debug: log.msg(repr(line)) | log.debug(repr(line)) | def lineReceived(self, line): "Process the input from the client" line = string.strip(line) if self.debug: log.msg(repr(line)) |
log.err() | log.err(e) | def lineReceived(self, line): "Process the input from the client" line = string.strip(line) if self.debug: log.msg(repr(line)) |
def processCommand(self, command, *args): | def processCommand(self, cmd, *args): | def processCommand(self, command, *args): if self.blocked != None: self.blocked.append((method,args)) return |
self.blocked.append((method,args)) | log.debug('FTP is queueing command: %s' % cmd) self.blocked.append((cmd,args)) | def processCommand(self, command, *args): if self.blocked != None: self.blocked.append((method,args)) return |
command = command.upper() method = getattr(self, "ftp_%s" % command) | cmd = cmd.upper() if cmd not in ['USER','PASS'] and not self.shell: log.debug('ftp_%s returning, user not logged in' % cmd) self.reply(NOT_LOGGED_IN) return if cmd in ['RETR', 'STOR', 'LIST', 'PORT']: if not self.dtpInstance: assert self.blocked == None self.blocked = [(cmd,args)] log.debug('during dtp setup, blocke... | def processCommand(self, command, *args): if self.blocked != None: self.blocked.append((method,args)) return |
return FTPError("command not implemented") | log.debug("SOMETHING IS SCREWY") def _unblock(self, *_): log.debug('_unblock running') commands = self.blocked self.blocked = None while commands and self.blocked is None: cmd, args = commands.pop(0) self.processCommand(cmd, *args) if self.blocked is not None: self.blocked.extend(commands) def _ebDtpInstance(self, _... | def processCommand(self, command, *args): if self.blocked != None: self.blocked.append((method,args)) return |
if self.debug: log.msg(RESPONSE[key] % s + ENDLN) | log.debug(RESPONSE[key] % s + ENDLN) | def reply(self, key, s = ''): if string.find(RESPONSE[key], '%s') > -1: if self.debug: log.msg(RESPONSE[key] % s + ENDLN) self.transport.write(RESPONSE[key] % s + ENDLN) else: if self.debug: log.msg(RESPONSE[key] + ENDLN) self.transport.write(RESPONSE[key] + ENDLN) |
if self.debug: log.msg(RESPONSE[key] + ENDLN) | log.debug(RESPONSE[key] + ENDLN) | def reply(self, key, s = ''): if string.find(RESPONSE[key], '%s') > -1: if self.debug: log.msg(RESPONSE[key] % s + ENDLN) self.transport.write(RESPONSE[key] % s + ENDLN) else: if self.debug: log.msg(RESPONSE[key] + ENDLN) self.transport.write(RESPONSE[key] + ENDLN) |
if self.debug: log.msg('_createActiveDTP') | log.debug('_createActiveDTP') | def _createActiveDTP(self): if self.debug: log.msg('_createActiveDTP') raise NotImplementedError() |
if self.debug: log.msg('_createPassiveDTP') | log.debug('_createPassiveDTP') | def _createPassiveDTP(self): """creates a dtp listening on self.dtpFactory.dtpPort for connections""" if self.debug: log.msg('_createPassiveDTP') # TODO: figure out what happens if there's an existing ACTV # DTP connection and the client calls PASV self.dtpTxfrMode = PASV # ensure state is correct if not self... |
if not self.HUMAN_READABLE_PASV_PORT: port = 0 else: port = 2122 self.dtpFactory.dtpPort = reactor.listenTCP(port, self.dtpFactory) | self.dtpPort = reactor.listenTCP(0, self.dtpFactory) return self.dtpFactory.deferred | def _createPassiveDTP(self): """creates a dtp listening on self.dtpFactory.dtpPort for connections""" if self.debug: log.msg('_createPassiveDTP') # TODO: figure out what happens if there's an existing ACTV # DTP connection and the client calls PASV self.dtpTxfrMode = PASV # ensure state is correct if not self... |
if self.debug: log.msg('_createDTP') | log.debug('_createDTP') | def _createDTP(self): if self.debug: log.msg('_createDTP') if self.dtpTxfrMode != ACTV: return self._createPassiveDTP() return self._createActiveDTP() |
return self._createPassiveDTP() return self._createActiveDTP() | d = self._createPassiveDTP() else: d = self._createActiveDTP() d = self.dtpFactory.deferred d.addCallback(debugDeferred, 'dtpFactory deferred') d.addCallback(self._unblock) d.addErrback(self._ebDtpInstance) | def _createDTP(self): if self.debug: log.msg('_createDTP') if self.dtpTxfrMode != ACTV: return self._createPassiveDTP() return self._createActiveDTP() |
if self.debug: log.msg('cleanupDTP') if self.dtpFactory: if self.dtpFactory.dtpPort: if self.debug: log.msg('self.dtpFactory.dtpPort.stopListening()') | log.debug('cleanupDTP') if hasattr(self.dtpPort, 'connected'): self.dtpPort.loseConnection() self.dtpPort.stopListening() | def cleanupDTP(self): """called when DTP connection exits""" if self.debug: log.msg('cleanupDTP') if self.dtpFactory: if self.dtpFactory.dtpPort: if self.debug: log.msg('self.dtpFactory.dtpPort.stopListening()') self.dtpFactory = None |
def doDTPCommand(self, command, args=None): '''causes the DTP to commence with an action''' if self.debug: log.msg('FTP.doDTPCommand: %s' % command) if not self.dtpFactory: self._createDTP() self.dtpFactory.doCommand(command, args) | self.dtpInstance = None self.dtpPort = None def _doDTPCommand(self, cmd, arg): if self.blocked is None: self.blocked = [] try: f = getattr(self.dtpInstance, "dtp_%s" % cmd, None) except AttributeError, e: log.err('SOMETHING IS SCREWY IN _doDTPCommand') raise e defer.maybeDeferred(f, arg ).addCallback(self._cbDTPComma... | def cleanupDTP(self): """called when DTP connection exits""" if self.debug: log.msg('cleanupDTP') if self.dtpFactory: if self.dtpFactory.dtpPort: if self.debug: log.msg('self.dtpFactory.dtpPort.stopListening()') self.dtpFactory = None |
if self.debug: log.msg('ftp_USER params: %s' % params) | log.debug('ftp_USER params: %s' % params) | def ftp_USER(self, params): """Get the login name, and reset the session PASS is expected to follow |
if self.debug: log.msg('ftp_PASS params: %s' % params) | log.debug('ftp_PASS params: %s' % params) | def ftp_PASS(self, params): """Authorize the USER and the submitted password |
if self.debug: log.msg('ftp_LIST: %s' % params) | log.debug('ftp_LIST: %s' % params) | def ftp_LIST(self, params=''): """ This command causes a list to be sent from the server to the passive DTP. If the pathname specifies a directory or other group of files, the server should transfer a list of files in the specified directory. If the pathname specifies a file then the server should send current inform... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.