Пример #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
Пример #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
Пример #3
0
def main():
    usage = '%prog [options] CMD CMDARGS'
    description = 'Command line interaction with a VNC server'
    op = VNCDoToolOptionParser(usage=usage, description=description)
    op.add_option('-d', '--display', action='store', metavar='DISPLAY',
        type='int', default=0,
        help='connect to vnc server display :DISPLAY [%default]')
    op.add_option('-p', '--password', action='store', metavar='PASSwORD',
        help='use password to access server')
    op.add_option('-s', '--server', action='store', metavar='ADDRESS',
        default='127.0.0.1',
        help='connect to vnc server at ADDRESS[:PORT] [%default]')
    op.add_option('-v', '--verbose', action='store_true')

    opts, args = op.parse_args()
    if not len(args):
        op.error('no command provided')

    factory = VNCDoToolFactory()
    try:
        host, port = opts.server.split(':')
    except ValueError:
        host = opts.server
        port = opts.display + 5900

    if opts.password:
        factory.password = opts.password

    if opts.verbose:
        log.msg('connecting to %s:%s' % (host, port))
        factory.logger = log.msg
        log.startLogging(sys.stdout)

    if opts.verbose:
        factory.deferred.addCallbacks(log_connected)

    build_command_list(factory, args)

    factory.deferred.addCallback(stop)
    factory.deferred.addErrback(error)

    reactor.connectTCP(host, int(port), factory)
    reactor.exit_status = 1

    reactor.run()

    sys.exit(reactor.exit_status)
Пример #4
0
def build_tool(options, args):
    factory = VNCDoToolFactory()
    factory.protocol = VNCDoCLIClient

    if options.verbose:
        factory.deferred.addCallbacks(log_connected)

    if args == ['-']:
        lex = shlex.shlex(posix=True)
        lex.whitespace_split = True
        args = list(lex)

    build_command_list(factory, args, options.delay, options.warp)

    factory.deferred.addCallback(stop)
    factory.deferred.addErrback(error)

    reactor.connectTCP(options.host, int(options.port), factory)
    reactor.exit_status = 1

    return factory
Пример #5
0
def build_tool(options, args):
    factory = VNCDoToolFactory()
    factory.protocol = VNCDoCLIClient

    if options.verbose:
        factory.deferred.addCallbacks(log_connected)

    if args == ['-']:
        lex = shlex.shlex(posix=True)
        lex.whitespace_split = True
        args = list(lex)

    build_command_list(factory, args, options.delay, options.warp)

    factory.deferred.addCallback(stop)
    factory.deferred.addErrback(error)

    reactor.connectTCP(options.host, int(options.port), factory)
    reactor.exit_status = 1

    return factory
Пример #6
0
def build_tool(options, args):
    factory = VNCDoToolFactory()
    if options.verbose:
        factory.deferred.addCallbacks(log_connected)

    if args == ['-']:
        lex = shlex.shlex(posix=True)
        lex.whitespace_split = True
        args = list(lex)
    elif os.path.isfile(args[0]):
        lex = shlex.shlex(open(args[0]), posix=True)
        lex.whitespace_split = True
        args = list(lex)
    build_command_list(factory, args, options.delay)

    factory.deferred.addCallback(stop)
    factory.deferred.addErrback(error)

    reactor.connectTCP(options.host, int(options.port), factory)
    reactor.exit_status = 1

    return factory
Пример #7
-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