Exemplo n.º 1
0
def get_VNC_info_subprocess(port):
    if type(port) == int:
        vncClient = internet.TCPClient('localhost', port, RFBFactory())
    else:
        vncClient = internet.UNIXClient(port, RFBFactory())
    vncClient.startService()
    reactor.run()
    return VNC_data
Exemplo n.º 2
0
 def testUNIX(self):
     # FIXME: This test is far too dense.  It needs comments.
     #  -- spiv, 2004-11-07
     s = service.MultiService()
     s.startService()
     factory = protocol.ServerFactory()
     factory.protocol = TestEcho
     TestEcho.d = defer.Deferred()
     t = internet.UNIXServer("echo.skt", factory)
     t.setServiceParent(s)
     factory = protocol.ClientFactory()
     factory.protocol = Foo
     factory.d = defer.Deferred()
     factory.line = None
     internet.UNIXClient("echo.skt", factory).setServiceParent(s)
     factory.d.addCallback(self.assertEqual, b"lalala")
     factory.d.addCallback(lambda x: s.stopService())
     factory.d.addCallback(lambda x: TestEcho.d)
     factory.d.addCallback(self._cbTestUnix, factory, s)
     return factory.d
Exemplo n.º 3
0
 def testUNIX(self):
     # FIXME: This test is far too dense.  It needs comments.
     #  -- spiv, 2004-11-07
     if not interfaces.IReactorUNIX(reactor, None):
         raise unittest.SkipTest, "This reactor does not support UNIX domain sockets"
     s = service.MultiService()
     s.startService()
     factory = protocol.ServerFactory()
     factory.protocol = TestEcho
     TestEcho.d = defer.Deferred()
     t = internet.UNIXServer('echo.skt', factory)
     t.setServiceParent(s)
     factory = protocol.ClientFactory()
     factory.protocol = Foo
     factory.d = defer.Deferred()
     factory.line = None
     internet.UNIXClient('echo.skt', factory).setServiceParent(s)
     factory.d.addCallback(self.assertEqual, 'lalala')
     factory.d.addCallback(lambda x: s.stopService())
     factory.d.addCallback(lambda x: TestEcho.d)
     factory.d.addCallback(self._cbTestUnix, factory, s)
     return factory.d
Exemplo n.º 4
0
    def testVolatile(self):
        factory = protocol.ServerFactory()
        factory.protocol = wire.Echo
        t = internet.UNIXServer("echo.skt", factory)
        t.startService()
        self.failIfIdentical(t._port, None)
        t1 = copy.copy(t)
        self.assertIsNone(t1._port)
        t.stopService()
        self.assertIsNone(t._port)
        self.assertFalse(t.running)

        factory = protocol.ClientFactory()
        factory.protocol = wire.Echo
        t = internet.UNIXClient("echo.skt", factory)
        t.startService()
        self.failIfIdentical(t._connection, None)
        t1 = copy.copy(t)
        self.assertIsNone(t1._connection)
        t.stopService()
        self.assertIsNone(t._connection)
        self.assertFalse(t.running)
Exemplo n.º 5
0
    def testUNIX(self):
        # FIXME: This test is far too dense.  It needs comments.
        #  -- spiv, 2004-11-07
        if not interfaces.IReactorUNIX(reactor, None):
            raise unittest.SkipTest, "This reactor does not support UNIX domain sockets"
        s = service.MultiService()
        s.startService()
        factory = protocol.ServerFactory()
        factory.protocol = TestEcho
        TestEcho.d = defer.Deferred()
        t = internet.UNIXServer('echo.skt', factory)
        t.setServiceParent(s)

        class Foo(basic.LineReceiver):
            def connectionMade(self):
                self.transport.write('lalala\r\n')

            def lineReceived(self, line):
                self.factory.line = line
                self.transport.loseConnection()

        factory = protocol.ClientFactory()
        factory.protocol = Foo
        factory.line = None
        internet.UNIXClient('echo.skt', factory).setServiceParent(s)
        util.spinWhile(lambda: factory.line is None)
        self.assertEqual(factory.line, 'lalala')
        util.wait(defer.maybeDeferred(s.stopService))
        util.wait(TestEcho.d)

        TestEcho.d = defer.Deferred()
        factory.line = None
        s.startService()
        util.spinWhile(lambda: factory.line is None)
        self.assertEqual(factory.line, 'lalala')

        # Cleanup the reactor
        util.wait(defer.maybeDeferred(s.stopService))
        util.wait(TestEcho.d)
Exemplo n.º 6
0
    def testVolatile(self):
        if not interfaces.IReactorUNIX(reactor, None):
            raise unittest.SkipTest, "This reactor does not support UNIX domain sockets"
        factory = protocol.ServerFactory()
        factory.protocol = wire.Echo
        t = internet.UNIXServer('echo.skt', factory)
        t.startService()
        self.failIfIdentical(t._port, None)
        t1 = copy.copy(t)
        self.assertIdentical(t1._port, None)
        t.stopService()
        self.assertIdentical(t._port, None)
        self.failIf(t.running)

        factory = protocol.ClientFactory()
        factory.protocol = wire.Echo
        t = internet.UNIXClient('echo.skt', factory)
        t.startService()
        self.failIfIdentical(t._connection, None)
        t1 = copy.copy(t)
        self.assertIdentical(t1._connection, None)
        t.stopService()
        self.assertIdentical(t._connection, None)
        self.failIf(t.running)
Exemplo n.º 7
0
 def connectUNIX(self, address, factory, timeout=30):
     s = internet.UNIXClient(address, factory, timeout)
     s.setServiceParent(self.app)