def preloop(self): '''Update the prompt before cmdloop, which is where the prompt is used. ''' Cmd.preloop(self) self.update_prompt()
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 = {}
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 = {}
def preloop(self): # Variables self._hist = [] self._locals = {} self._globals = {} # Sets up command completion Cmd.preloop(self)
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
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 = {}
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
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)
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)
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()
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)
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)
def preloop(self): Cmd.preloop(self) if os.path.exists(HISTORY): logd('Reading history') rl.read_history_file(HISTORY)
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)
def preloop(self): Cmd.preloop(self) if os.path.exists(HISTORY): logd('Reading history') rl.read_history_file(HISTORY)
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 = {}
def preloop(self): Cmd.preloop(self) self.load_tokens() self.prompt = '(VK-CLI)'
def preloop(self): Cmd.preloop(self) self._hist = [] self._locals = {} self._globals = {}
def preloop(self): Cmd.preloop(self) self._hist = [] self._locals = {} self._globals = {}