def makeService(self, options): cookie = options["cookie"] if not cookie: cookie = readCookie() nodeName = buildNodeName(options["nodename"]) process = Process(nodeName, cookie) rservice = RabbitMQControlService(process) site = server.Site(resource.IResource(rservice)) srvc = internet.TCPServer(int(options["port"]), site) return srvc
def makeService(self, options): cookie = options['cookie'] if not cookie: cookie = readCookie() methodsHolder = options.get('methods', {}) if methodsHolder: methodsHolder = namedAny(methodsHolder) nodeName = buildNodeName(options['nodename']) epmd = PersistentPortMapperService(methodsHolder, nodeName, cookie) return epmd
def main(nodeName, server=False): cookie = readCookie() nodeName = buildNodeName(nodeName) process = Process(nodeName, cookie) process.registerModule("api", RemoteCalls(process)) if server: process.listen().addCallback(lambda x: testReceive(process)) else: testPing(process) reactor.run()
def make_rabbitmqctl_service(): """ Boiler plate construction of txrabbitmq Service. Usually Twisted Service libraries provide a makeService method. """ from twotp import Process, readCookie, buildNodeName cookie = readCookie() nodeName = buildNodeName('txrabbitmq') process = Process(nodeName, cookie) service = RabbitMQControlService(process, 'rabbit') return service
def setUp(self): self.protocol = ErlangProcessProtocol() self.protocol.onDataReceived = Deferred() executables = which("erl") if not executables: raise SkipTest("No erl process") self.cookie = "twotp_cookie" self.erlangName = "twotp_erlang_test" self.nodeName = buildNodeName("twotp_python_test") args = [executables[0], "-setcookie", self.cookie, "-sname", self.erlangName] self.process = reactor.spawnProcess( self.protocol, executables[0], args, env=dict(os.environ)) # We wait for input to be available return self.protocol.onDataReceived
# Copyright (c) 2007-2009 Thomas Herve <*****@*****.**>. # See LICENSE for details. """ Example emulating rabbitmqctl, just calling list_vhosts for now. """ from twisted.internet import reactor from twotp import Process, readCookie, buildNodeName def testListVhost(process): def cb(resp): print resp reactor.stop() def eb(error): print "Got error", error reactor.stop() process.callRemote("rabbit", "rabbit_access_control", "list_vhosts" ).addCallback(cb).addErrback(eb) if __name__ == "__main__": cookie = readCookie() nodeName = buildNodeName("twotp-rabbit") process = Process(nodeName, cookie) reactor.callWhenRunning(testListVhost, process) reactor.run()
def main(): cookie = readCookie() nodeName = buildNodeName('nodename') process = Process(nodeName, cookie) manager = MnesiaManager(process)