Ejemplo n.º 1
0
def connect(server, password=None):
    """ Connect to a VNCServer and return a Client instance that is usable
    in the main thread of non-Twisted Python Applications, EXPERIMENTAL.

    >>> from vncdotool import threaded
    >>> client = threaded.connect('host')
    >>> client.keyPress('c')
    >>> client.join()

    You may then call any regular VNCDoToolClient method on client from your
    application code.

    If you are using a GUI toolkit or other major async library please read
    http://twistedmatrix.com/documents/13.0.0/core/howto/choosing-reactor.html
    for a better method of intergrating vncdotool.
    """
    observer = PythonLoggingObserver()
    observer.start()

    factory = VNCDoToolFactory()
    if password is not None:
        factory.password = password
    client = ThreadedVNCClientProxy(factory)

    host, port = command.parse_host(server)
    client.connect(host, port)
    client.start()

    return client
Ejemplo n.º 2
0
def connect(server, password=None):
    """ Connect to a VNCServer and return a Client instance that is usable
    in the main thread of non-Twisted Python Applications, EXPERIMENTAL.

    >>> from vncdotool import threaded
    >>> client = threaded.connect('host')
    >>> client.keyPress('c')
    >>> client.join()

    You may then call any regular VNCDoToolClient method on client from your
    application code.

    If you are using a GUI toolkit or other major async library please read
    http://twistedmatrix.com/documents/13.0.0/core/howto/choosing-reactor.html
    for a better method of intergrating vncdotool.
    """
    observer = PythonLoggingObserver()
    observer.start()

    factory = VNCDoToolFactory()
    if password is not None:
        factory.password = password
    client = ThreadedVNCClientProxy(factory)

    host, port = command.parse_host(server)
    client.connect(host, port)
    client.start()

    return client
Ejemplo n.º 3
0
 def test_default(self):
     command.parse_host(self.options)
     assert self.options.host == '127.0.0.1'
     assert self.options.port == 5900
Ejemplo n.º 4
0
 def test_just_display(self):
     host, port = command.parse_host(':10')
     assert host == '127.0.0.1'
     assert port == 5910
Ejemplo n.º 5
0
 def test_host_port(self):
     host, port = command.parse_host('10.11.12.13::4444')
     assert host == '10.11.12.13'
     assert port == 4444
Ejemplo n.º 6
0
 def test_default(self):
     host, port = command.parse_host('')
     assert host == '127.0.0.1'
     assert port == 5900
Ejemplo n.º 7
0
 def test_just_display(self):
     host, port = command.parse_host(':10')
     assert host == '127.0.0.1'
     assert port == 5910
Ejemplo n.º 8
0
 def test_host_port(self):
     host, port = command.parse_host('10.11.12.13::4444')
     assert host == '10.11.12.13'
     assert port == 4444
Ejemplo n.º 9
0
 def test_default(self):
     command.parse_host(self.options)
     assert self.options.host == '127.0.0.1'
     assert self.options.port == 5900
Ejemplo n.º 10
0
 def test_just_port(self):
     self.options.server = '::1111'
     command.parse_host(self.options)
     assert self.options.host == '127.0.0.1'
     assert self.options.port == 1111
Ejemplo n.º 11
0
 def test_just_display(self):
     self.options.server = ':10'
     command.parse_host(self.options)
     assert self.options.host == '127.0.0.1'
     assert self.options.port == 5910
Ejemplo n.º 12
0
 def test_just_host(self):
     self.options.server = '10.11.12.13'
     command.parse_host(self.options)
     assert self.options.server == '10.11.12.13'
     assert self.options.port == 5900
Ejemplo n.º 13
0
 def test_host_port(self):
     self.options.server = '10.11.12.13::4444'
     command.parse_host(self.options)
     assert self.options.host == '10.11.12.13'
     assert self.options.port == 4444
Ejemplo n.º 14
0
 def test_host_display(self):
     self.options.server = '10.11.12.13:10'
     command.parse_host(self.options)
     assert self.options.host == '10.11.12.13'
     assert self.options.port == 5910
Ejemplo n.º 15
0
 def test_default(self):
     host, port = command.parse_host('')
     assert host == '127.0.0.1'
     assert port == 5900
Ejemplo n.º 16
0
 def test_host_display(self):
     host, port = command.parse_host('10.11.12.13:10')
     assert host == '10.11.12.13'
     assert port == 5910
Ejemplo n.º 17
0
 def test_host_display(self):
     self.options.server = '10.11.12.13:10'
     command.parse_host(self.options)
     assert self.options.host == '10.11.12.13'
     assert self.options.port == 5910
Ejemplo n.º 18
0
 def test_just_host(self):
     host, port = command.parse_host('10.11.12.13')
     assert host == '10.11.12.13'
     assert port == 5900
Ejemplo n.º 19
0
 def test_host_port(self):
     self.options.server = '10.11.12.13::4444'
     command.parse_host(self.options)
     assert self.options.host == '10.11.12.13'
     assert self.options.port == 4444
Ejemplo n.º 20
0
 def test_just_port(self):
     host, port = command.parse_host('::1111')
     assert host == '127.0.0.1'
     assert port == 1111
Ejemplo n.º 21
0
 def test_just_host(self):
     self.options.server = '10.11.12.13'
     command.parse_host(self.options)
     assert self.options.server == '10.11.12.13'
     assert self.options.port == 5900
Ejemplo n.º 22
0
 def test_host_display(self):
     host, port = command.parse_host('10.11.12.13:10')
     assert host == '10.11.12.13'
     assert port == 5910
Ejemplo n.º 23
0
 def test_just_display(self):
     self.options.server = ':10'
     command.parse_host(self.options)
     assert self.options.host == '127.0.0.1'
     assert self.options.port == 5910
Ejemplo n.º 24
0
 def test_just_host(self):
     host, port = command.parse_host('10.11.12.13')
     assert host == '10.11.12.13'
     assert port == 5900
Ejemplo n.º 25
0
 def test_just_port(self):
     self.options.server = '::1111'
     command.parse_host(self.options)
     assert self.options.host == '127.0.0.1'
     assert self.options.port == 1111
Ejemplo n.º 26
0
 def test_just_port(self):
     host, port = command.parse_host('::1111')
     assert host == '127.0.0.1'
     assert port == 1111
Ejemplo n.º 27
-1
def connect(server, password=None):
    """ Connect to a VNCServer and return a Client instance that is usable
    in the main thread of non-Twisted Python Applications, EXPERIMENTAL.

    >>> from vncdotool import api
    >>> client = api.connect('host')
    >>> client.keyPress('c')
    >>> api.shutdown()

    You may then call any regular VNCDoToolClient method on client from your
    application code.

    If you are using a GUI toolkit or other major async library please read
    http://twistedmatrix.com/documents/13.0.0/core/howto/choosing-reactor.html
    for a better method of intergrating vncdotool.
    """
    if not reactor.running:
        global _THREAD
        _THREAD = threading.Thread(target=reactor.run, name='Twisted',
                         kwargs={'installSignalHandlers': False})
        _THREAD.daemon = True
        _THREAD.start()

        observer = PythonLoggingObserver()
        observer.start()

    factory = VNCDoToolFactory()
    if password is not None:
        factory.password = password
    client = ThreadedVNCClientProxy(factory)

    host, port = command.parse_host(server)
    client.connect(host, port)

    return client