Example #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
Example #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
Example #3
0
 def test_default(self):
     command.parse_host(self.options)
     assert self.options.host == '127.0.0.1'
     assert self.options.port == 5900
Example #4
0
 def test_just_display(self):
     host, port = command.parse_host(':10')
     assert host == '127.0.0.1'
     assert port == 5910
Example #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
Example #6
0
 def test_default(self):
     host, port = command.parse_host('')
     assert host == '127.0.0.1'
     assert port == 5900
Example #7
0
 def test_just_display(self):
     host, port = command.parse_host(':10')
     assert host == '127.0.0.1'
     assert port == 5910
Example #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
Example #9
0
 def test_default(self):
     command.parse_host(self.options)
     assert self.options.host == '127.0.0.1'
     assert self.options.port == 5900
Example #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
Example #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
Example #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
Example #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
Example #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
Example #15
0
 def test_default(self):
     host, port = command.parse_host('')
     assert host == '127.0.0.1'
     assert port == 5900
Example #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
Example #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
Example #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
Example #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
Example #20
0
 def test_just_port(self):
     host, port = command.parse_host('::1111')
     assert host == '127.0.0.1'
     assert port == 1111
Example #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
Example #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
Example #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
Example #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
Example #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
Example #26
0
 def test_just_port(self):
     host, port = command.parse_host('::1111')
     assert host == '127.0.0.1'
     assert port == 1111
Example #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