def save_history(self): try: readline.write_history_file(self.history_file) except FileNotFoundError: print( red('Unable to write history file to ' '{}.'.format(self.history_file)))
def init_completer(self): try: import rlcompleter readline.parse_and_bind("tab: complete") readline.set_completer_delims("") readline.write_history_file(os.path.join(dxpy.config.get_user_conf_dir(), '.dx_history')) readline.clear_history() readline.set_completer() except: pass
def input_loop(): if os.path.exists(HISTORY_FILENAME): readline.read_history_file(HISTORY_FILENAME) print('Max history file length:', readline.get_history_length()) print('Startup history:', get_history_items()) try: while True: line = input('Prompt ("stop" to quit): ') if line == 'stop': break if line: print('Adding {!r} to the history'.format(line)) finally: print('Final history:', get_history_items()) readline.write_history_file(HISTORY_FILENAME)
def input_loop(): if os.path.exists(HISTORY_FILENAME): readline.read_history_file(HISTORY_FILENAME) print('Lunghezza max file storico:', readline.get_history_length()) print('Storico di partenza:', get_history_items()) try: while True: line = input('Prompt ("stop" per uscire): ') if line == 'stop': break if line: print('Aggiunta di {!r} allo storico'.format(line)) finally: print('Storico finale:', get_history_items()) readline.write_history_file(HISTORY_FILENAME)
def input_loop(): if os.path.exists(HISTORY_FILENAME): readline.read_history_file(HISTORY_FILENAME) print('Max history file length:', readline.get_history_length()) print('Startup history:', get_history_items()) try: while True: line = input('Prompt ("stop" to quit): ') if line == 'stop': break if line: print('Adding {!r} to the history'.format(line)) finally: print('Final history:', get_history_items()) readline.write_history_file(HISTORY_FILENAME)
def _process_input(self): if sys.version_info[0] >= 3: input_impl = input else: input_impl = raw_input self._print_startup_message() while True: self._idle.wait() expression = "" line = "" while len(expression) == 0 or line.endswith("\\"): try: if len(expression) == 0: line = input_impl("[%s]" % self._prompt_string + "-> ") else: line = input_impl("... ") except EOFError: # An extra newline after EOF to exit the REPL cleanly print("\nThank you for using Frida!") return if len(line.strip()) > 0: if len(expression) > 0: expression += "\n" expression += line.rstrip("\\") if HAVE_READLINE: try: readline.write_history_file(HIST_FILE) except IOError: pass if expression.endswith("?"): # Help feature self._print_help(expression) elif expression.startswith("%"): # "Magic" commands self._do_magic(expression) elif expression in ("quit", "q", "exit"): print("Thank you for using Frida!") return elif expression == "help": print("Frida help 1.0!") else: self._idle.clear() self._reactor.schedule(lambda: self._send_expression(expression))
def save_history(self): readline.write_history_file(self.history_file)
self.parser.file_scanner.position + 1 if self.parser.file_scanner.position + 1 <= len(self.parser.file_scanner.lines) else "EOF", scope)) else: inp = raw_input( "<%s>:%s|%s: " % ( "NO FILE", self.position + 1, scope)) except Exception, e: inp = 'quit' self.addline(StringIO.StringIO(inp)) tokens = super(InteractiveVisionScanner, self).next() else: # If it's a subcommand, when we're done, we're done raise finally: readline.write_history_file(os.path.expanduser("~/.vision_history")) self.advance() return tokens @property def scopes(self): scopes = [] try: command = next(com for com in reversed(self.parser.children) if com.parsed and not com.error) scopes.extend(command.scopes) if command.scopechange > 0: # The most recent command opened a scope, # include it in the list scopes.append(command) elif command.scopechange < 0: # The most recent command closed a scope,
def save_history(self): readline.write_history_file(self.history_file)
def exit(self): readline.write_history_file(self.history)
def save_hist(): readline.write_history_file(_HISTFILE)
def save_history(): readline.write_history_file(hfn)
def postloop(self): try: readline.write_history_file(self.HISTORY_FILE) except (OSError, IOError) as e: warn("Can't write history file: %s" % str(e))
def save_hist(): readline.write_history_file(_HISTFILE)
def postloop(self): ''' Save history on exit. ''' readline.write_history_file('.psiturk_history')
def save_history(self, histfile): import readline readline.write_history_file(histfile)
def _process_input(self): if sys.version_info[0] >= 3: input_impl = input else: input_impl = raw_input self._print_startup_message() self._ready.wait() while True: expression = "" line = "" while len(expression) == 0 or line.endswith("\\"): try: if len(expression) == 0: line = input_impl("[%s]" % self._prompt_string + "-> ") else: line = input_impl("... ") except EOFError: # An extra newline after EOF to exit the REPL cleanly print("\nThank you for using Frida!") return if len(line.strip()) > 0: if len(expression) > 0: expression += "\n" expression += line.rstrip("\\") if HAVE_READLINE: try: readline.write_history_file(HIST_FILE) except IOError: pass if expression.endswith("?"): try: self._print_help(expression) except Exception as ex: error = ex.message sys.stdout.write(Fore.RED + Style.BRIGHT + error['name'] + Style.RESET_ALL + ": " + error['message'] + "\n") sys.stdout.flush() elif expression.startswith("%"): self._do_magic(expression[1:].rstrip()) elif expression in ("exit", "quit", "q"): print("Thank you for using Frida!") return elif expression == "help": print("Help: #TODO :)") else: try: (t, value) = self._evaluate(expression) if t in ('function', 'undefined', 'null'): output = t elif t == 'binary': output = hexdump(value).rstrip("\n") else: output = json.dumps(value, sort_keys=True, indent=4, separators=(",", ": ")) except Exception as ex: error = ex.message output = Fore.RED + Style.BRIGHT + error['name'] + Style.RESET_ALL + ": " + error['message'] sys.stdout.write(output + "\n") sys.stdout.flush()
def save_history(historyPath=historyPath): import gnureadline gnureadline.write_history_file(historyPath)
def _process_input(self): if sys.version_info[0] >= 3: input_impl = input else: input_impl = raw_input self._print_startup_message() self._ready.wait() while True: expression = "" line = "" while len(expression) == 0 or line.endswith("\\"): try: if len(expression) == 0: line = input_impl("[%s]" % self._prompt_string + "-> ") else: line = input_impl("... ") except EOFError: # An extra newline after EOF to exit the REPL cleanly print("\nThank you for using Frida!") return if len(line.strip()) > 0: if len(expression) > 0: expression += "\n" expression += line.rstrip("\\") if HAVE_READLINE: try: readline.write_history_file(HIST_FILE) except IOError: pass if expression.endswith("?"): try: self._print_help(expression) except Exception as ex: error = ex.message sys.stdout.write(Fore.RED + Style.BRIGHT + error['name'] + Style.RESET_ALL + ": " + error['message'] + "\n") sys.stdout.flush() elif expression.startswith("%"): self._do_magic(expression[1:].rstrip()) elif expression in ("exit", "quit", "q"): print("Thank you for using Frida!") return elif expression == "help": print("Help: #TODO :)") else: try: (t, value) = self._evaluate(expression) if t in ('function', 'undefined', 'null'): output = t elif t == 'raw': output = hexdump(value).rstrip("\n") else: output = json.dumps(value, sort_keys=True, indent=4, separators=(",", ": ")) except Exception as ex: error = ex.message output = Fore.RED + Style.BRIGHT + error[ 'name'] + Style.RESET_ALL + ": " + error['message'] sys.stdout.write(output + "\n") sys.stdout.flush()
def postloop(self): ''' Save history on exit. ''' readline.write_history_file('.psiturk_history')
from query.parser import DatabaseREPL from query import davisbase_constants as dc import gnureadline as readline import pathlib, sys hist_file = str(pathlib.Path.home()) + '/.davisdb_history' open(hist_file, 'a+').close() readline.read_history_file(hist_file) if __name__ == '__main__': if not sys.stdin.isatty(): dc.PROMPT_NAME = '' dc.PROMPT_MORE = '' prompt = DatabaseREPL() prompt.cmdloop_with_keyboard_interrupt() readline.write_history_file(hist_file)