예제 #1
0
#!/usr/bin/env python
from demo import Demo

if __name__ == '__main__':
    demo = Demo([
        #x   ,   y,   z, yaw, sleep
        [0.0, -1.0, 0.5, 0, 2],
        [1.5, -1.0, 0.5, 0, 2],
        [-0.5, -1.0, 0.75, 0, 2],
        [-0.5, -1.5, 0.5, 0, 2],
        [0.0, -1.0, 0.5, 0, 0],
    ])
    demo.run()
예제 #2
0
def main():
    """SimDem CLI interpreter"""

    commands = config.modes
    command_string = ""
    for command in commands:
        command_string = command_string + command + "|"
    command_string = command_string[0:len(command_string) - 1]

    p = optparse.OptionParser("%prog [" + command_string +
                              "] <options> DEMO_NAME",
                              version=config.SIMDEM_VERSION)
    p.add_option(
        '--style',
        '-s',
        default="tutorial",
        help=
        "The style of simulation you want to run. 'tutorial' (the default) will print out all text and pause for user input before running commands. 'simulate' will not print out the text but will still pause for input."
    )
    p.add_option('--path',
                 '-p',
                 default="demo_scripts/",
                 help="The Path to the demo scripts directory.")
    p.add_option(
        '--auto',
        '-a',
        default="False",
        help=
        "Set to 'true' (or 'yes') to prevent the application waiting for user keypresses between commands. Set to 'no' when running in test mode to allow users to step through each test."
    )
    p.add_option(
        '--test',
        '-t',
        default="False",
        help=
        "If set to anything other than False the output of the command will be compared to the expected results in the sript. Any failures will be reported"
    )
    p.add_option(
        '--fastfail',
        default="True",
        help=
        "If set to anything other than True test execution has will stop on the first failure. This has no affect if running in any mode other than 'test'."
    )
    p.add_option('--debug',
                 '-d',
                 default="False",
                 help="Turn on debug logging by setting to True.")
    p.add_option(
        '--webui',
        '-w',
        default="False",
        help=
        "If set to anything other than False will interact with the user through a Web UI rather than the CLI."
    )

    options, arguments = p.parse_args()

    if not options.path.endswith("/"):
        options.path += "/"

    if options.auto == "False":
        is_automatic = False
    else:
        is_automatic = True

    if options.test == "False":
        is_test = False
    else:
        is_test = True

    if options.fastfail == "True":
        is_fast_fail = True
    else:
        is_fast_fail = False

    if options.style == "simulate":
        simulate = True
    elif options.style == 'tutorial':
        simulate = False
    else:
        print("Unknown style (--style, -s): " + options.style)
        exit(1)

    if options.debug.lower() == "true":
        config.is_debug = True

    if len(arguments) == 2:
        script_dir = options.path + arguments[1]
    else:
        script_dir = options.path

    cmd = None
    if len(arguments) > 0:
        cmd = arguments[0]
        # 'run' is deprecated in the CLI, but not yet removed from code
        if cmd == "tutorial":
            cmd = "run"
        if cmd == "test":
            is_test = True
            is_auto = True

    filename = "README.md"
    is_docker = os.path.isfile('/.dockerenv')
    demo = Demo(is_docker, script_dir, filename, simulate, is_automatic,
                is_test)

    if options.webui == "False":
        ui = Ui()
    else:
        ui = WebUi(config.port)
        print("Server started. Listening on port " + str(ui.port))
        print("Point your browser at " + str(ui.port))
        print()
        while not ui.ready:
            time.sleep(0.25)
            print("Waiting for client connection")
        cmd = None

    demo.set_ui(ui)
    demo.run(cmd)
예제 #3
0
#!/usr/bin/env python
from demo import Demo

if __name__ == '__main__':
    demo = Demo(
        [
            #x   ,   y,   z, yaw, sleep
            [0.0 , 0.0, 0.5, 0, 2],
            [1.5 , 0.0, 0.5, 0, 2],
            [-1.5 , 0.0, 0.75, 0, 2],
            [-1.5 , 0.5, 0.5, 0, 2],
            [0.0 , 0.0, 0.5, 0, 0],
            #[0.0 , 1.0, 0.3, 0],
            #[1.0 , 1.0, 0.5, 0],
            #[0.0 , 0.5, 0.2, 0],
            #[0.0 , 0.5, 0.0, 0],
        ]
    )
    demo.run()
예제 #4
0
파일: main.py 프로젝트: lachie83/simdem
def main():
    """SimDem CLI interpreter"""

    commands = ["tutorial", "demo", "learn", "test", "script"]
    command_string = ""
    for command in commands:
        command_string = command_string + command + "|"
    command_string = command_string[0:len(command_string) - 1]

    p = optparse.OptionParser("%prog [" + command_string +
                              "] <options> DEMO_NAME",
                              version=config.SIMDEM_VERSION)
    p.add_option(
        '--style',
        '-s',
        default="tutorial",
        help=
        "The style of simulation you want to run. 'tutorial' (the default) will print out all text and pause for user input before running commands. 'simulate' will not print out the text but will still pause for input."
    )
    p.add_option('--path',
                 '-p',
                 default="demo_scripts/",
                 help="The Path to the demo scripts directory.")
    p.add_option(
        '--auto',
        '-a',
        default="False",
        help=
        "Set to 'true' (or 'yes') to prevent the application waiting for user keypresses between commands. Set to 'no' when running in test mode to allow users to step through each test."
    )
    p.add_option(
        '--test',
        '-t',
        default="False",
        help=
        "If set to anything other than False the output of the command will be compared to the expected results in the sript. Any failures will be reported"
    )
    p.add_option(
        '--fastfail',
        default="True",
        help=
        "If set to anything other than True test execution has will stop on the first failure. This has no affect if running in any mode other than 'test'."
    )

    options, arguments = p.parse_args()

    if not options.path.endswith("/"):
        options.path += "/"

    if options.auto == "False":
        is_automatic = False
    else:
        is_automatic = True

    if options.test == "False":
        is_test = False
    else:
        is_test = True

    if options.style == "simulate":
        simulate = True
    elif options.style == 'tutorial':
        simulate = False
    else:
        print("Unknown style (--style, -s): " + options.style)
        exit(1)

    if len(arguments) == 2:
        script_dir = options.path + arguments[1]
    else:
        script_dir = options.path

    ui = Ui()

    if len(arguments) == 0:
        cmd = "unkown"
        while not cmd in commands:
            cmd = ui.get_command()
    else:
        cmd = arguments[0]

    if cmd == "tutorial":
        cmd = "run"

    filename = "script.md"
    is_docker = os.path.isfile('/.dockerenv')
    if cmd == "run":
        demo = Demo(ui, is_docker, script_dir, filename, simulate,
                    is_automatic, is_test)
        demo.run()
    elif cmd == "demo":
        demo = Demo(ui, is_docker, script_dir, filename, True, is_automatic,
                    is_test)
        demo.run()
    elif cmd == "test":
        is_automatic = not options.auto.lower() == "no"
        is_test = True and options.test
        is_fast_fail = options.fastfail == "True"
        demo = Demo(ui,
                    is_docker,
                    script_dir,
                    filename,
                    simulate,
                    is_automatic,
                    is_test,
                    is_fast_fail=is_fast_fail)
        demo.run()
    elif cmd == "script":
        print(get_bash_script(script_dir))
    elif cmd == "learn":
        demo = Demo(ui,
                    is_docker,
                    script_dir,
                    filename,
                    simulate,
                    is_automatic,
                    is_test,
                    is_learning=True)
        demo.run()
    else:
        print("Unknown command: " + cmd)
        print("Run with --help for guidance.")
예제 #5
0
"""
Used to run the demo CLI app.
"""

from demo import Demo

if __name__ == '__main__':
    Demo.run()
예제 #6
0
파일: main.py 프로젝트: rgardler/simdem
def main():
    """SimDem CLI interpreter"""

    commands = config.modes
    command_string = ""
    for command in commands:
        command_string = command_string + command + "|"
    command_string = command_string[0:len(command_string)-1]
    
    p = optparse.OptionParser("%prog [" + command_string + "] <options> DEMO_NAME", version=config.SIMDEM_VERSION)
    p.add_option('--style', '-s', default="tutorial",
                 help="The style of simulation you want to run. 'tutorial' (the default) will print out all text and pause for user input before running commands. 'simulate' will not print out the text but will still pause for input.")
    p.add_option('--path', '-p', default="demo_scripts/",
                 help="The Path to the demo scripts directory.")
    p.add_option('--auto', '-a', default="False",
                 help="Set to 'true' (or 'yes') to prevent the application waiting for user keypresses between commands. Set to 'no' when running in test mode to allow users to step through each test.")
    p.add_option('--test', '-t', default="False",
                 help="If set to anything other than False the output of the command will be compared to the expected results in the sript. Any failures will be reported")
    p.add_option('--fastfail', default="True",
                 help="If set to anything other than True test execution has will stop on the first failure. This has no affect if running in any mode other than 'test'.")
    p.add_option('--debug', '-d', default="False",
                 help="Turn on debug logging by setting to True.")
    p.add_option('--webui', '-w', default="False",
                 help="If set to anything other than False will interact with the user through a Web UI rather than the CLI.")
    p.add_option('--output', '-o', default="log",
                 help="Format of the output. The default is `log` which will output all stdout data. Other options are `summary` which provides a summary of the execution status and `json`")

    options, arguments = p.parse_args()

    if not options.path.endswith("/"):
        options.path += "/"

    if options.auto == "False":
        is_automatic = False
    else:
        is_automatic = True

    if options.test == "False":
        is_test = False
    else:
        is_test = True
    
    if options.fastfail == "True":
        is_fast_fail= True
    else:
        is_fast_fail= False
        
    if options.style == "simulate":
        simulate = True
    elif options.style == 'tutorial':
        simulate = False
    else:
        print("Unknown style (--style, -s): " + options.style)
        exit(1)

    if options.debug.lower() == "true":
        config.is_debug = True

    if len(arguments) == 2:
        script_dir = options.path + arguments[1]
    else:
        script_dir = options.path

    cmd = None
    if len(arguments) > 0:
        cmd = arguments[0]
        # 'run' is deprecated in the CLI, but not yet removed from code
        if cmd == "tutorial":
            cmd = "run"
        if cmd == "test":
            is_test = True
            is_auto = True

    filename = "README.md"
    is_docker = os.path.isfile('/.dockerenv')
    demo = Demo(is_docker, script_dir, filename, simulate, is_automatic, is_test, is_fast_fail, output_format=options.output);

    if options.webui == "False":
        ui = Ui()
    else:
        ui = WebUi(config.port)
        print("Server started. Listening on port " + str(ui.port))
        print("Point your browser at " + str(ui.port))
        print()
        while not ui.ready:
            time.sleep(0.25)
            print("Waiting for client connection")
        cmd = None

    demo.set_ui(ui)
    demo.run(cmd)