예제 #1
0
    if len(sys.argv) > 1:
        action = sys.argv[1]

    if action == None:
        switcher = {
            "default": 2323,
            "custom": config.get("custom_port"),
            "shivaLR": 2424,
            "jetDirect": 2525,
            "firstClassMsg": 2626,
            "ambitCable": 2727,
            "nortel": 2828,
            "arubaSwitch": 2929,
            "busybox": 2121
        }
        port = type = switcher.get(config.get("device_profile"),
                                   lambda: "Invalid type")
        srv = Telnetd(port)
        signal.signal(signal.SIGINT, signal_handler)
        srv.run()
    elif action == "import":
        fname = sys.argv[2]
        import_file(fname)
    elif action == "rerun":
        fname = sys.argv[2]
        rerun_file(fname)
    elif action == "shell":
        test_shell()
    else:
        print "Command " + action + " unknown."
예제 #2
0
        if arg == "-c":
            if i + 1 < len(sys.argv):
                configFile = sys.argv[i + 1]
                print("Using config file " + configFile)
                i += 1
                continue
            else:
                print("warning: expected argument after \"-c\"")
        else:
            action = arg

    if configFile:
        config.loadUserConfig(configFile)

    if action == None:
        socket.setdefaulttimeout(15)

        srv = Telnetd(config.get("telnet_addr"), config.get("telnet_port"))
        signal.signal(signal.SIGINT, signal_handler)
        srv.run()
    elif action == "import":
        fname = sys.argv[2]
        import_file(fname)
    elif action == "rerun":
        fname = sys.argv[2]
        rerun_file(fname)
    elif action == "shell":
        test_shell()
    else:
        print("Command " + action + " unknown.")
예제 #3
0

def signal_handler(signal, frame):
    dbg('Ctrl+C')
    srv.stop()


if not os.path.exists("samples"):
    os.makedirs("samples")

if __name__ == "__main__":
    action = None

    if len(sys.argv) > 1:
        action = sys.argv[1]

    if action == None:
        srv = Telnetd(2223)
        signal.signal(signal.SIGINT, signal_handler)
        srv.run()
    elif action == "import":
        fname = sys.argv[2]
        import_file(fname)
    elif action == "rerun":
        fname = sys.argv[2]
        rerun_file(fname)
    elif action == "shell":
        test_shell()
    else:
        print "Command " + action + " unknown."