Пример #1
0
def main():
    """Command line interface to remote call
    """
    from evasion.director import utils
    from optparse import OptionParser

    utils.log_init(logging.DEBUG)
    log = logging.getLogger("evasion.director.viewpointdirect.main")

    parser = OptionParser()

    parser.add_option("-c",
                      "--command",
                      action="store",
                      dest="cmd",
                      default='get_uri',
                      help="Command to use. Default: get_uri")
    parser.add_option(
        "-a",
        "--args",
        action="store",
        dest="args",
        default='',
        help="The comm port the browser is using. Default: Nothing")
    parser.add_option("-p",
                      "--port",
                      action="store",
                      dest="port",
                      default=7055,
                      help="The comm port the browser is using. Default: 7055")
    parser.add_option(
        "-i",
        "--host",
        action="store",
        dest="host",
        default='127.0.0.1',
        help=
        "The comm interface the browser is listening on. Default: 127.0.0.1")

    (options, args) = parser.parse_args()

    b = DirectBrowserCalls(port=options.port, interface=options.host)

    log.info("Running command '%s' with args '%s'." %
             (options.cmd, options.args))

    if options.cmd == 'get_uri':
        b.getBrowserUri()

    elif options.cmd == 'set_uri':
        b.setBrowserUri(options.args)

    elif options.cmd == 'call':
        b.callFunction(options.args)

    elif options.cmd == 'exit':
        b.browserQuit()

    else:
        msg = "Unknown command '%s'." % options.cmd
        log.error(msg)
        sys.stderr.write(msg)
        sys.exit(1)

    sys.exit(0)
Пример #2
0
#!/usr/bin/env python
"""
Use nosetests to run the unit tests for this project.

"""
import os
import sys
import logging

import nose

sys.path.insert(0, "./lib")

from evasion.director import utils
utils.log_init(logging.DEBUG)

result = nose.core.TestProgram().success
nose.result.end_capture()

def main():
    """Command line interface to remote call
    """
    from evasion.director import utils
    from optparse import OptionParser

    utils.log_init(logging.DEBUG)
    log = logging.getLogger("evasion.director.viewpointdirect.main")

    parser = OptionParser()

    parser.add_option(
        "-c", "--command", action="store", dest="cmd", default="get_uri", help="Command to use. Default: get_uri"
    )
    parser.add_option(
        "-a",
        "--args",
        action="store",
        dest="args",
        default="",
        help="The comm port the browser is using. Default: Nothing",
    )
    parser.add_option(
        "-p",
        "--port",
        action="store",
        dest="port",
        default=7055,
        help="The comm port the browser is using. Default: 7055",
    )
    parser.add_option(
        "-i",
        "--host",
        action="store",
        dest="host",
        default="127.0.0.1",
        help="The comm interface the browser is listening on. Default: 127.0.0.1",
    )

    (options, args) = parser.parse_args()

    b = DirectBrowserCalls(port=options.port, interface=options.host)

    log.info("Running command '%s' with args '%s'." % (options.cmd, options.args))

    if options.cmd == "get_uri":
        b.getBrowserUri()

    elif options.cmd == "set_uri":
        b.setBrowserUri(options.args)

    elif options.cmd == "call":
        b.callFunction(options.args)

    elif options.cmd == "exit":
        b.browserQuit()

    else:
        msg = "Unknown command '%s'." % options.cmd
        log.error(msg)
        sys.stderr.write(msg)
        sys.exit(1)

    sys.exit(0)