Beispiel #1
0
def do_remote_command(command, *args, **kwargs):
    client = AnyConsensoProcess()
    client.start()
    furl = client.furl()
    tub = Tub()
    tub.startService()

    def got_error(err):
        print "Error while calling command remotely", err
        reactor.stop()

    def got_result(res):
        print(res)

    def got_remote(remote):
        d = remote.callRemote(command, *args, **kwargs)
        d.addCallback(got_result)
        d.addCallback(lambda res: reactor.stop())
        d.addErrback(got_error)
        return d

    d = tub.getReference(furl)
    d.addCallback(got_remote)
    d.addErrback(got_error)
    reactor.run()
Beispiel #2
0
class Test_ConsensoProcess(unittest.TestCase):
    def setUp(self):
        if os.path.exists("/tmp/pidfile"):
            os.unlink("/tmp/pidfile")
        self.ic = AnyConsensoProcess(pidfile="/tmp/pidfile")
        self.ic.start()

    def test_creates_daemon(self):
        pid = int(open('/tmp/pidfile', 'r').read())
        self.assertGreater(pid, 0)

    def test_got_pid(self):
        pid = int(open('/tmp/pidfile', 'r').read())
        self.assertEqual(pid, self.ic.pid)

    def test_got_furl(self):
        self.assert_(self.ic.furl())

    def test_second_process(self):
        """ Should just return with the pid and furl of previous one """
        second_ic = AnyConsensoProcess(pidfile="/tmp/pidfile")
        self.assertEquals(second_ic.pid, self.ic.pid)
        self.assertEquals(second_ic.furl(), self.ic.furl())

    def tearDown(self):
        self.ic.shutdown()
Beispiel #3
0
 def test_second_process(self):
     """ Should just return with the pid and furl of previous one """
     second_ic = AnyConsensoProcess(pidfile="/tmp/pidfile")
     self.assertEquals(second_ic.pid, self.ic.pid)
     self.assertEquals(second_ic.furl(), self.ic.furl())
Beispiel #4
0
 def setUp(self):
     if os.path.exists("/tmp/pidfile"):
         os.unlink("/tmp/pidfile")
     self.ic = AnyConsensoProcess(pidfile="/tmp/pidfile")
     self.ic.start()