Пример #1
0
    def preloop(self):
        '''Update the prompt before cmdloop, which is where the prompt
        is used.

        '''
        Cmd.preloop(self)
        self.update_prompt()
Пример #2
0
 def preloop(self):
     """Initialization before prompting user for commands.
        Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub.
     """
     Cmd.preloop(self)   ## sets up command completion
     self._hist    = []      ## No history yet
     self._locals  = {}      ## Initialize execution namespace for user
     self._globals = {}
Пример #3
0
 def preloop(self):
     """Initialization before prompting user for commands.
        Despite the claims in the Cmd documentaion, Cmd.preloop() is not a stub.
     """
     Cmd.preloop(self)  ## sets up command completion
     self._hist = self.load_history()
     self._locals = {}  ## Initialize execution namespace for user
     self._globals = {}
Пример #4
0
    def preloop(self):

        # Variables
        self._hist = []
        self._locals = {}
        self._globals = {}

        # Sets up command completion
        Cmd.preloop(self)
Пример #5
0
 def preloop(self):
     Cmd.preloop(self)
     if self.completekey:
         try:
             import readline
             delims = readline.get_completer_delims()
             delims = "".join([x for x in delims if x not in "-:@"])
             readline.set_completer_delims(delims)
         except ImportError:
             pass
Пример #6
0
 def preloop(self):
     '''
     Initialization before prompting user for commands.
     Despite the claims in the Cmd documentation, Cmd.preloop() is not a
     stub.
     '''
     Cmd.preloop(self)  # sets up command completion
     self._hist = []  # No history yet
     self._locals = {}  # Initialize execution namespace for user
     self._globals = {}
Пример #7
0
 def preloop(self):
     Cmd.preloop(self)
     if self.completekey:
         try:
             import readline
             delims = readline.get_completer_delims()
             delims = "".join([x for x in delims if x not in "-:@"])
             readline.set_completer_delims(delims)
         except ImportError:
             pass
Пример #8
0
    def preloop(self):
        from os import popen, path
        from scrounger.utils.general import execute
        import scrounger.modules

        _Cmd.preloop(self)  # sets up command completion

        self._session = _Session("default")
        self._session.prompt = self.prompt

        self._sessions = _load_sessions(_SESSION_FILE)

        readline.set_completer_delims(' \t\n')
        if path.exists(_HISTORY_FILE):
            readline.read_history_file(_HISTORY_FILE)
Пример #9
0
    def preloop(self):
        """
        This function prepares loop by loading readline history file.

        :return: None
        """

        # call predecessor function
        Cmd.preloop(self)

        try:
            # load history
            readline.read_history_file(sys.argv[0] + '.history')

        except Exception as error:
            self._error("history error: %s\n" % error)
Пример #10
0
async def async_cmdloop_threaded_stdin(looping_cmd: cmd.Cmd) -> None:
    stdin = phile.asyncio.ThreadedTextIOBase(looping_cmd.stdin)
    stdout = looping_cmd.stdout
    looping_cmd.preloop()
    if looping_cmd.intro:
        await asyncio.to_thread(stdout.write, looping_cmd.intro)
        await asyncio.to_thread(stdout.flush)
    is_stopping = False
    while not is_stopping:
        await asyncio.to_thread(stdout.write, looping_cmd.prompt)
        await asyncio.to_thread(stdout.flush)
        try:
            next_command = await stdin.readline()
        except (EOFError, ValueError):
            next_command = "EOF\n"
        is_stopping = process_command(looping_cmd, next_command)
    looping_cmd.postloop()
Пример #11
0
    def preloop(self):
        from os import popen, path
        from scrounger.utils.general import execute
        import scrounger.modules

        _Cmd.preloop(self)  ## sets up command completion

        self._rows, self._columns = popen('stty size', 'r').read().split()
        self._rows, self._columns = int(self._rows), int(self._columns)
        if self._columns < 128: self._columns = 128

        # need to add / to then replace it
        modules_path = "{}/".format(scrounger.modules.__path__[0])
        modules = execute("find {} -name '*.py'".format(modules_path))

        self._available_modules = [
            module.replace(modules_path, "").replace(".py", "")
            for module in modules.split("\n") if module and "__" not in module
        ]

        # add custom modules
        modules_path = "{}/modules/".format(_SCROUNGER_HOME)
        modules = execute("find {} -name \"*.py\"".format(modules_path))

        # add path to sys.path
        _path.append(modules_path)

        #self._custom_modules = [
        self._available_modules += [
            module.replace(modules_path, "").replace(".py", "")
            for module in modules.split("\n") if module and "__" not in module
        ]

        # fix for macos
        self._available_modules = [
            module[1:] if module.startswith("/") else module
            for module in sorted(self._available_modules)
        ]

        execute("mkdir -p {}".format(self._global_options["output"]))

        readline.set_completer_delims(' \t\n')
        if path.exists(_HISTORY_FILE):
            readline.read_history_file(_HISTORY_FILE)
Пример #12
0
 def preloop(self):
     print("Welcome to the PiGlow Spark interpreter.\n" \
         + "Type '" + GREEN_TEXT + "help" + NORMAL_TEXT \
         + "' if you don't know what to do.")
     Cmd.preloop(self)
Пример #13
0
 def preloop(self):
     Cmd.preloop(self)
     if os.path.exists(HISTORY):
         logd('Reading history')
         rl.read_history_file(HISTORY)
Пример #14
0
 def preloop(self):
     """If synchronous, wait for the shell activation"""
     Cmd.preloop(self)
     if self.synchronous_commands:
         logging.info('Wait for %s activation', self.name)
         self.wrapper.synchronous_thread_out(self.termination_string)
Пример #15
0
 def preloop(self):
     Cmd.preloop(self)
     if os.path.exists(HISTORY):
         logd('Reading history')
         rl.read_history_file(HISTORY)
Пример #16
0
 def preloop(self):
     """Initialization"""
     Cmd.preloop(self)  # sets up command completion
     self._hist = []  # No history yet
     self._locals = {}  # Initialize execution namespace for user
     self._globals = {}
Пример #17
0
 def preloop(self):
     Cmd.preloop(self)
     self.load_tokens()
     self.prompt = '(VK-CLI)'
Пример #18
0
 def preloop(self):
     Cmd.preloop(self)
     
     self._hist = []
     self._locals = {}
     self._globals = {}
Пример #19
0
    def preloop(self):
        Cmd.preloop(self)

        self._hist = []
        self._locals = {}
        self._globals = {}