Пример #1
0
def start_ipython(options):
    comports = options.devices
    d = list()

    if not options.no_logfile and not os.path.exists(LOG_DIR):
        print("Creating log directory: {}".format(os.path.abspath(LOG_DIR)))
        os.mkdir(LOG_DIR)

    for dev_com in comports:

        acidev = Uart(port=dev_com,
                        baudrate=options.baudrate,
                        device_name=dev_com.split("/")[-1])
        
        logger = configure_logger(acidev.device_name)
        d.append(Interactive(acidev, logger))

    m = Mesh(d[0])
    py = Pyaci(m)

    py.run()

    for dev in d:
        dev.close()
    raise SystemExit(0)
Пример #2
0
def start_ipython(input_options):
    #print("Started IPython Function")
    global options
    options = input_options

    if options.log_level == 1:
        options.log_level = logging.ERROR
    elif options.log_level == 2:
        options.log_level = logging.WARNING
    elif options.log_level == 3:
        options.log_level = logging.INFO
    else:
        options.log_level = logging.DEBUG
        
    colorama.init()
    comports = options.devices
    global d
    d = list()

    # Print out a mini intro to the interactive session --
    # Start with white and then magenta to keep the session white
    # (workaround for a bug in ipython)
    # colors = {"c_default": colorama.Fore.WHITE + colorama.Style.BRIGHT,
    #          "c_highlight": colorama.Fore.YELLOW + colorama.Style.BRIGHT,
    #          "c_text": colorama.Fore.CYAN + colorama.Style.BRIGHT}

    # print(USAGE_STRING.format(**colors))

    if not options.no_logfile and not os.path.exists(LOG_DIR):
        print("Creating log directory: {}".format(os.path.abspath(LOG_DIR)))
        os.mkdir(LOG_DIR)
    
    for dev_com in comports:
        d.append(Interactive(Uart(port=dev_com,
                                  baudrate=options.baudrate,
                                  device_name=dev_com.split("/")[-1])))
    
    device = d[0]
    send = device.acidev.write_aci_cmd  # NOQA: Ignore unused variable

    # Set iPython configuration
    ipython_config = traitlets.config.get_config()
    if options.no_logfile:
        ipython_config.TerminalInteractiveShell.logstart = False
        ipython_config.InteractiveShellApp.db_log_output = False
    else:
        dt = DateTime.DateTime()
        logfile = "{}/{}-{}-{}-{}_interactive_session.log".format(
            LOG_DIR, dt.yy(), dt.dayOfYear(), dt.hour(), dt.minute())

        ipython_config.TerminalInteractiveShell.logstart = True
        ipython_config.InteractiveShellApp.db_log_output = True
        ipython_config.TerminalInteractiveShell.logfile = logfile

    ipython_config.TerminalInteractiveShell.confirm_exit = False
    ipython_config.InteractiveShellApp.multiline_history = True
    ipython_config.InteractiveShellApp.log_level = logging.DEBUG

    return device
Пример #3
0
def start_ipython(options):
    colorama.init()
    comports = options.devices
    d = list()

    # Print out a mini intro to the interactive session --
    # Start with white and then magenta to keep the session white
    # (workaround for a bug in ipython)
    colors = {
        "c_default": colorama.Fore.WHITE + colorama.Style.BRIGHT,
        "c_highlight": colorama.Fore.YELLOW + colorama.Style.BRIGHT,
        "c_text": colorama.Fore.CYAN + colorama.Style.BRIGHT
    }

    print(USAGE_STRING.format(**colors))

    if not options.no_logfile and not os.path.exists(LOG_DIR):
        print("Creating log directory: {}".format(os.path.abspath(LOG_DIR)))
        os.mkdir(LOG_DIR)

    for dev_com in comports:
        d.append(
            Interactive(
                Uart(port=dev_com,
                     baudrate=options.baudrate,
                     device_name=dev_com.split("/")[-1])))

    device = d[0]
    send = device.acidev.write_aci_cmd  # NOQA: Ignore unused variable

    db = MeshDB("database/example_database.json")
    p = Provisioner(device, db)
    p.scan_start()
    time.sleep(10)
    p.scan_stop()
    print(str(p.unprov_list))

    # Set iPython configuration
    ipython_config = traitlets.config.get_config()
    if options.no_logfile:
        ipython_config.TerminalInteractiveShell.logstart = False
        ipython_config.InteractiveShellApp.db_log_output = False
    else:
        dt = DateTime.DateTime()
        logfile = "{}/{}-{}-{}-{}_interactive_session.log".format(
            LOG_DIR, dt.yy(), dt.dayOfYear(), dt.hour(), dt.minute())

        ipython_config.TerminalInteractiveShell.logstart = True
        ipython_config.InteractiveShellApp.db_log_output = True
        ipython_config.TerminalInteractiveShell.logfile = logfile

    ipython_config.TerminalInteractiveShell.confirm_exit = False
    ipython_config.InteractiveShellApp.multiline_history = True
    ipython_config.InteractiveShellApp.log_level = logging.DEBUG

    #IPython.embed(config=ipython_config)
    for dev in d:
        dev.close()
    raise SystemExit(0)
Пример #4
0
    def __init__(self, port):
        self.db = MeshDB("database/example_database.json")

        self.device = Interactive(Uart(port))
        self.device.acidev.add_packet_recipient(self._event_handler)

        self.provisioner = Provisioner(self.device, self.db)

        self.cc = ConfigurationClient(self.db)
        self.device.model_add(self.cc)
Пример #5
0
def start_ipython(options):
    colorama.init()
    comports = options.devices
    d = list()

    # Print out a mini intro to the interactive session --
    # Start with white and then magenta to keep the session white
    # (workaround for a bug in ipython)
    colors = {
        "c_default": colorama.Fore.WHITE + colorama.Style.BRIGHT,
        "c_highlight": colorama.Fore.YELLOW + colorama.Style.BRIGHT,
        "c_text": colorama.Fore.CYAN + colorama.Style.BRIGHT
    }

    print(USAGE_STRING.format(**colors))

    for dev_com in comports:
        d.append(
            Interactive(
                Uart(port=dev_com,
                     baudrate=options.baudrate,
                     device_name=dev_com.split("/")[-1])))

    device = d[0]
    send = device.acidev.write_aci_cmd  # NOQA: Ignore unused variable

    # Set iPython configuration
    c = config.get_config()
    if options.no_logfile:
        c.TerminalInteractiveShell.logstart = False
        c.InteractiveShellApp.db_log_output = False
    else:
        dt = DateTime.DateTime()
        logfile = "interactive_session_{}-{}-{}-{}.log".format(
            dt.yy(), dt.dayOfYear(), dt.hour(), dt.minute())

        c.TerminalInteractiveShell.logstart = True
        c.InteractiveShellApp.db_log_output = True
        c.TerminalInteractiveShell.logfile = logfile

    c.TerminalInteractiveShell.confirm_exit = False
    c.InteractiveShellApp.multiline_history = True
    c.InteractiveShellApp.log_level = logging.DEBUG

    IPython.embed(config=c)
    for dev in d:
        dev.close()
    raise SystemExit(0)