本文整理汇总了Python中readline.write_history_file方法的典型用法代码示例。如果您正苦于以下问题:Python readline.write_history_file方法的具体用法?Python readline.write_history_file怎么用?Python readline.write_history_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块readline的用法示例。
在下文中一共展示了readline.write_history_file方法的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run_console
点赞 7
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def run_console(glob):
import readline
import rlcompleter
import atexit
import code
history_path = os.path.expanduser("~/.python_history")
def save_history(history_path=history_path):
readline.write_history_file(history_path)
if os.path.exists(history_path):
readline.read_history_file(history_path)
atexit.register(save_history)
readline.set_completer(rlcompleter.Completer(glob).complete)
readline.parse_and_bind("tab: complete")
code.InteractiveConsole(locals=glob).interact()
开发者ID:Deepwalker,项目名称:pundler,代码行数:20,
示例2: __init__
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def __init__(self):
"""Create the main mode.
If titus.inspector.defs.CONFIG_DIRECTORY_EXISTS is ``True``, get the readline history file from the user's titus.inspector.defs.CONFIG_DIRECTORY.
"""
if CONFIG_DIRECTORY_EXISTS:
self.historyPath = os.path.join(os.path.expanduser(CONFIG_DIRECTORY), self.historyFileName)
if not os.path.exists(self.historyPath):
open(self.historyPath, "w").close()
self.active = True
self.tabCompleter = TabCompleter(self)
readline.read_history_file(self.historyPath)
readline.set_completer(self.tabCompleter.complete)
def writehistory():
if self.active:
readline.write_history_file(self.historyPath)
atexit.register(writehistory)
开发者ID:modelop,项目名称:hadrian,代码行数:22,
示例3: save_history
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def save_history(self):
if self.history_file_full_path is not None:
global readline
if readline is None:
try:
import readline
except ImportError:
return
try:
readline.write_history_file(self.history_file_full_path)
except IOError:
e = sys.exc_info()[1]
warnings.warn("Cannot save history file, reason: %s" % str(e))
#------------------------------------------------------------------------------
# Main loop
# Debugging loop.
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:20,
示例4: enable_history
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def enable_history(self, history_file: str) -> None:
self.histfile = os.path.expanduser(history_file)
try:
readline.read_history_file(self.histfile)
except FileNotFoundError:
pass
except PermissionError:
self.histfile = ""
print(
f"Warning: You don't have permissions to read {history_file} and\n"
" the command history of this session won't be saved.\n"
" Either change this file's permissions, recreate it,\n"
" or use an alternate path with the SDB_HISTORY_FILE\n"
" environment variable.")
return
readline.set_history_length(1000)
atexit.register(readline.write_history_file, self.histfile)
开发者ID:delphix,项目名称:sdb,代码行数:19,
示例5: setup
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def setup(self):
""" Initialization of third-party libraries
Setting interpreter history.
Setting appropriate completer function.
:return:
"""
if not os.path.exists(self.history_file):
open(self.history_file, 'a+').close()
readline.read_history_file(self.history_file)
readline.set_history_length(self.history_length)
atexit.register(readline.write_history_file, self.history_file)
readline.parse_and_bind('set enable-keypad on')
readline.set_completer(self.complete)
readline.set_completer_delims(' \t\n;')
readline.parse_and_bind("tab: complete")
开发者ID:d0ubl3g,项目名称:Industrial-Security-Auditing-Framework,代码行数:22,
示例6: init_readline
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def init_readline(complete_method, histfile=None):
"""init the readline library if available"""
try:
import readline
readline.parse_and_bind("tab: complete")
readline.set_completer(complete_method)
string = readline.get_completer_delims().replace(':', '')
readline.set_completer_delims(string)
if histfile is not None:
try:
readline.read_history_file(histfile)
except IOError:
pass
import atexit
atexit.register(readline.write_history_file, histfile)
except:
print('readline si not available :-(')
开发者ID:jlachowski,项目名称:clonedigger,代码行数:19,
示例7: hook_readline_hist
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def hook_readline_hist():
try:
import readline
except ImportError:
return
histfile = os.environ['HOME'] + '/.web_develop_history' # 定义一个存储历史记录的文件地址
readline.parse_and_bind('tab: complete')
try:
readline.read_history_file(histfile)
except IOError:
pass # It doesn't exist yet.
def savehist():
try:
readline.write_history_file(histfile)
except:
print 'Unable to save Python command history'
atexit.register(savehist)
开发者ID:dongweiming,项目名称:web_develop,代码行数:21,
示例8: postloop
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def postloop(self):
"""Take care of any unfinished business.
Despite the claims in the Cmd documentaion, Cmd.postloop() is not a stub.
"""
try:
if readline:
readline.write_history_file(sys.argv[0] + ".history")
except Exception as err:
if not isinstance(err, IOError):
self.stdout.write("history error: %s\n" % err)
# clean up command completion
cmd.Cmd.postloop(self)
if self.interactive:
self.stdout.write("Exiting...\n")
# tell the core we have stopped
core.deferred(core.stop)
开发者ID:JoelBender,项目名称:bacpypes,代码行数:21,
示例9: save_history
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def save_history(self):
if self.history_file_full_path is not None:
global readline
if readline is None:
try:
import readline
except ImportError:
return
try:
readline.write_history_file(self.history_file_full_path)
except IOError, e:
warnings.warn("Cannot save history file, reason: %s" % str(e))
#------------------------------------------------------------------------------
# Main loop
# Debugging loop.
开发者ID:debasishm89,项目名称:OpenXMolar,代码行数:19,
示例10: test_nonascii_history
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def test_nonascii_history(self):
readline.clear_history()
try:
readline.add_history("entrée 1")
except UnicodeEncodeError as err:
self.skipTest("Locale cannot encode test data: " + format(err))
readline.add_history("entrée 2")
readline.replace_history_item(1, "entrée 22")
readline.write_history_file(TESTFN)
self.addCleanup(os.remove, TESTFN)
readline.clear_history()
readline.read_history_file(TESTFN)
if is_editline:
# An add_history() call seems to be required for get_history_
# item() to register items from the file
readline.add_history("dummy")
self.assertEqual(readline.get_history_item(1), "entrée 1")
self.assertEqual(readline.get_history_item(2), "entrée 22")
开发者ID:ShikyoKira,项目名称:Project-New-Reign---Nemesis-Main,代码行数:20,
示例11: start
点赞 6
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def start(self):
self.cmd_manager.init()
log('%s started - GL HF!' % Color.colorify('frick', 'green highligh'))
readline.parse_and_bind('tab: complete')
hist = os.path.join(os.environ['HOME'], '.frick_history')
try:
readline.read_history_file(hist)
except IOError:
pass
atexit.register(readline.write_history_file, hist)
while True:
inp = six.moves.input().strip()
if len(inp) > 0:
self.cmd_manager.handle_command(inp)
开发者ID:iGio90,项目名称:frick,代码行数:19,
示例12: pause
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def pause(self):
"""Write the current history to the history file and stop readline."""
readline.write_history_file(self.historyPath)
readline.clear_history()
readline.set_completer()
self.active = False
开发者ID:modelop,项目名称:hadrian,代码行数:8,
示例13: remote_api_shell
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def remote_api_shell(servername, appid, path, secure, rpc_server_factory):
"""Actually run the remote_api_shell."""
remote_api_stub.ConfigureRemoteApi(appid, path, auth_func,
servername=servername,
save_cookies=True, secure=secure,
rpc_server_factory=rpc_server_factory)
remote_api_stub.MaybeInvokeAuthentication()
os.environ['SERVER_SOFTWARE'] = 'Development (remote_api_shell)/1.0'
if not appid:
appid = os.environ['APPLICATION_ID']
sys.ps1 = '%s> ' % appid
if readline is not None:
readline.parse_and_bind('tab: complete')
atexit.register(lambda: readline.write_history_file(HISTORY_PATH))
if os.path.exists(HISTORY_PATH):
readline.read_history_file(HISTORY_PATH)
if '' not in sys.path:
sys.path.insert(0, '')
preimported_locals = {
'memcache': memcache,
'urlfetch': urlfetch,
'users': users,
'db': db,
'ndb': ndb,
}
code.interact(banner=BANNER, local=preimported_locals)
开发者ID:elsigh,项目名称:browserscope,代码行数:40,
示例14: setup
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def setup():
history_file = "./.history"
if not os.path.exists(history_file):
open(history_file, 'a+').close()
readline.read_history_file(history_file)
readline.set_history_length(history_length)
atexit.register(readline.write_history_file, history_file)
readline.parse_and_bind('set enable-keypad on')
readline.set_completer(complete)
readline.set_completer_delims(' \t\n;')
readline.parse_and_bind("tab: complete")
开发者ID:WangYihang,项目名称:Exploit-Framework,代码行数:16,
示例15: do_exit
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def do_exit(self, line):
self.close()
if not self.execute_only_mode and readline.get_current_history_length() > 0:
readline.write_history_file(self.admin_history)
return True
开发者ID:aerospike,项目名称:aerospike-admin,代码行数:8,
示例16: main
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def main():
parser = argparse.ArgumentParser(description='King Phisher Interactive Database Console', conflict_handler='resolve')
utilities.argp_add_args(parser)
config_group = parser.add_mutually_exclusive_group(required=True)
config_group.add_argument('-c', '--config', dest='server_config', help='the server configuration file')
config_group.add_argument('-u', '--url', dest='database_url', help='the database connection url')
arguments = parser.parse_args()
if arguments.database_url:
database_connection_url = arguments.database_url
elif arguments.server_config:
server_config = configuration.ex_load_config(arguments.server_config)
database_connection_url = server_config.get('server.database')
else:
raise RuntimeError('no database connection was specified')
engine = manager.init_database(database_connection_url)
session = manager.Session()
username = getpass.getuser()
user = session.query(models.User).filter_by(name=username).first()
if user is None:
print("[-] no user {0} found in the database".format(username))
return
rpc_session = aaa.AuthenticatedSession(user=user)
console = code.InteractiveConsole(dict(
engine=engine,
graphql_query=graphql_query,
manager=manager,
models=models,
pprint=pprint.pprint,
rpc_session=rpc_session,
session=session
))
console.interact('starting interactive database console')
if os.path.isdir(os.path.dirname(history_file)):
readline.write_history_file(history_file)
开发者ID:rsmusllp,项目名称:king-phisher,代码行数:41,
示例17: save_history
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def save_history(self, histfile):
readline.write_history_file(histfile)
开发者ID:cj1324,项目名称:CGIShell,代码行数:4,
示例18: scapy_write_history_file
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def scapy_write_history_file(readline):
if conf.histfile:
try:
readline.write_history_file(conf.histfile)
except IOError,e:
try:
warning("Could not write history to [%s]\n\t (%s)" % (conf.histfile,e))
tmp = utils.get_temp_file(keep=True)
readline.write_history_file(tmp)
warning("Wrote history to [%s]" % tmp)
except:
warning("Cound not write history to [%s]. Discarded" % tmp)
开发者ID:medbenali,项目名称:CyberScan,代码行数:14,
示例19: execute
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def execute(self, fn, *args, **kwargs):
"""Execute the function and handle any exceptions."""
if readline is not None:
readline.set_history_length(10000)
readline.write_history_file(histfile)
try:
fn(*args, **kwargs)
except Exception as e:
self.handle_exception(e)
开发者ID:scriptotek,项目名称:alma-slipsomat,代码行数:11,
示例20: main
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def main():
url = sys.argv[1]
context['url'] = url
pkg = app.dispatch_url(url)
context['pkg'] = pkg
for item in pkg.to_dict().items():
print '{} = {}'.format(*item)
def prepare_readline():
import os
import readline
import atexit
readline.parse_and_bind('tab: complete')
histfile = os.path.expanduser("~/.daenerys_history")
try:
readline.read_history_file(histfile)
except IOError:
pass
def savehist(histfile):
readline.write_history_file(histfile)
atexit.register(savehist, histfile)
del atexit
try:
from IPython.terminal.interactiveshell import TerminalInteractiveShell
shell = TerminalInteractiveShell(user_ns=context)
shell.mainloop()
except ImportError:
import code
shell = code.InteractiveConsole(locals=context)
shell.runcode(prepare_readline.__code__)
shell.interact()
开发者ID:dongweiming,项目名称:daenerys,代码行数:38,
示例21: write_history_file
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def write_history_file(self, arg):
pass
开发者ID:kdart,项目名称:pycopia,代码行数:4,
示例22: savehist
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def savehist():
readline.write_history_file(PYHISTFILE)
开发者ID:kdart,项目名称:pycopia,代码行数:4,
示例23: save_history
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def save_history(history_file=history_file): # So you can use the up key to access the previous session commands
readline.write_history_file(history_file)
开发者ID:OWASP,项目名称:QRLJacking,代码行数:4,
示例24: __init__
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def __init__(self, path, console):
tab = readline.parse_and_bind("tab: complete")
if console == "pythem":
historyPath = ".pythem_history".format(path)
readline.read_history_file(historyPath)
completer = readline.set_completer(self.pythem)
# readline.write_history_file(historyPath)
if console == "xploit":
completer = readline.set_completer(self.xploit)
开发者ID:m4n3dw0lf,项目名称:pythem,代码行数:12,
示例25: _setup_history
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def _setup_history(history_file: Path, history_length: int) -> None:
if not history_file.exists():
with open(history_file, "a+") as history:
if is_libedit():
history.write("_HiStOrY_V2_\n\n")
readline.read_history_file(str(history_file))
readline.set_history_length(history_length)
atexit.register(readline.write_history_file, str(history_file))
开发者ID:fwkz,项目名称:riposte,代码行数:11,
示例26: _exit_func
点赞 5
# 需要导入模块: import readline [as 别名]
# 或者: from readline import write_history_file [as 别名]
def _exit_func(self):
readline.write_history_file(self.history_file)
print "Bye"
sys.exit(0)
开发者ID:salesforce,项目名称:threatshell,代码行数:6,
注:本文中的readline.write_history_file方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。