python类write_history_file()的实例源码

octopus_console.py 文件源码 项目:octopus 作者: octopus-platform 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def _save_history(self):
        hist_file = self.hist_file()
        if hist_file:
            readline.write_history_file(os.path.expanduser(hist_file))
main.py 文件源码 项目:CyberScan 作者: medbenali 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
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)
main.py 文件源码 项目:hostapd-mana 作者: adde88 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
PupyCmd.py 文件源码 项目:OSPTF 作者: xSploited 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def postcmd(self, stop, line):
        readline.write_history_file('.pupy_history')
main.py 文件源码 项目:CVE-2016-6366 作者: RiskSense-Ops 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
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)
pythonrc.py 文件源码 项目:pythonrc 作者: lonetwin 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def init_readline(self):
        """Activates history and tab completion
        """
        # - mainly borrowed from site.enablerlcompleter() from py3.4+

        # Reading the initialization (config) file may not be enough to set a
        # completion key, so we set one first and then read the file.
        readline_doc = getattr(readline, '__doc__', '')
        if readline_doc is not None and 'libedit' in readline_doc:
            readline.parse_and_bind('bind ^I rl_complete')
        else:
            readline.parse_and_bind('tab: complete')

        try:
            readline.read_init_file()
        except OSError:
            # An OSError here could have many causes, but the most likely one
            # is that there's no .inputrc file (or .editrc file in the case of
            # Mac OS X + libedit) in the expected location.  In that case, we
            # want to ignore the exception.
            pass

        if readline.get_current_history_length() == 0:
            # If no history was loaded, default to .python_history.
            # The guard is necessary to avoid doubling history size at
            # each interpreter exit when readline was already configured
            # see: http://bugs.python.org/issue5845#msg198636
            try:
                readline.read_history_file(config['HISTFILE'])
            except IOError:
                pass
            atexit.register(readline.write_history_file,
                            config['HISTFILE'])
        readline.set_history_length(config['HISTSIZE'])

        # - replace default completer
        readline.set_completer(self.improved_rlcompleter())

        # - enable auto-indenting
        readline.set_pre_input_hook(self.auto_indent_hook)
config.py 文件源码 项目:AlphaHooks 作者: AlphaHooks 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def stop_running(self):
        readline.write_history_file(self.HISTORY_PATH)
main.py 文件源码 项目:hakkuframework 作者: 4shadoww 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def scapy_write_history_file(readline):
    if conf.histfile:
        try:
            readline.write_history_file(conf.histfile)
        except IOError as 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)
PupyCmd.py 文件源码 项目:pupy 作者: ru-faraon 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def postcmd(self, stop, line):
        readline.write_history_file('.pupy_history')
athena_cli.py 文件源码 项目:athena-cli 作者: guardian 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def init_history(self):
        try:
            readline.read_history_file(self.hist_file)
            readline.set_history_length(HISTORY_FILE_SIZE)
            readline.write_history_file(self.hist_file)
        except IOError:
            readline.write_history_file(self.hist_file)

        atexit.register(self.save_history)
athena_cli.py 文件源码 项目:athena-cli 作者: guardian 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def save_history(self):
        try:
            readline.write_history_file(self.hist_file)
        except IOError:
            pass
interactive.py 文件源码 项目:fastweb 作者: BSlience 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def save_history(self, histfile):
        readline.set_history_length(1000)
        readline.write_history_file(histfile)
tool.py 文件源码 项目:fastweb 作者: BSlience 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def save_history(self, histfile):
        readline.set_history_length(1000)
        readline.write_history_file(histfile)
command.py 文件源码 项目:jiveplot 作者: haavee 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def __enter__(self):
        # we only do something if we have readline
        if not haveReadline:
            return self
        ## Set up the new history context
        self.historyFile      = os.path.join( os.getenv('HOME'), ".{0}.history".format(self.basename)) 
        (h, self.oldhistFile) = tempfile.mkstemp(prefix=self.basename, suffix=".hist", dir="/tmp")
        # only need the filename, really
        os.close(h)
        readline.write_history_file(self.oldhistFile)
        readline.clear_history()

        # if reading the old history fails, fail silently
        # (the file might not exist yet)
        try:
            readline.read_history_file(self.historyFile)
        except:
            pass

        # store the old completer, install our own one
        readline.parse_and_bind("tab: complete")
        #readline.parse_and_bind("C-c: backward-kill-line")
        self.oldCompleter = readline.get_completer()
        readline.set_completer(self.completer)
        return self

    # clean up the context
terminal.py 文件源码 项目:weevely3-stealth 作者: edibledinos 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _load_history(self):
        """Load history file and register dump on exit."""

        # Create a file without truncating it in case it exists.
        open(config.history_path, 'a').close()

        readline.set_history_length(100)
        try:
            readline.read_history_file(config.history_path)
        except IOError:
            pass
        atexit.register(readline.write_history_file,
            config.history_path)
session.py 文件源码 项目:zippy 作者: securesystemslab 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def init_python_session():
    """Construct new Python session. """
    from code import InteractiveConsole

    class SymPyConsole(InteractiveConsole):
        """An interactive console with readline support. """

        def __init__(self):
            InteractiveConsole.__init__(self)

            try:
                import readline
            except ImportError:
                pass
            else:
                import os
                import atexit

                readline.parse_and_bind('tab: complete')

                if hasattr(readline, 'read_history_file'):
                    history = os.path.expanduser('~/.sympy-history')

                    try:
                        readline.read_history_file(history)
                    except IOError:
                        pass

                    atexit.register(readline.write_history_file, history)

    return SymPyConsole()
scaffold.py 文件源码 项目:daenerys 作者: dongweiming 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
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()
main.py 文件源码 项目:trex-http-proxy 作者: alwye 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
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)
main.py 文件源码 项目:trex-http-proxy 作者: alwye 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def scapy_write_history_file(readline):
    if conf.histfile:
        try:
            readline.write_history_file(conf.histfile)
        except IOError as 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)
trex_console.py 文件源码 项目:trex-http-proxy 作者: alwye 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def save_console_history(self):
        if not os.path.exists(self._history_file_dir):
            # make the directory available for every user
            try:
                original_umask = os.umask(0)
                os.makedirs(self._history_file_dir, mode = 0o777)
            finally:
                os.umask(original_umask)


        # os.mknod(self._history_file)
        readline.write_history_file(self._history_file)
        return


问题


面经


文章

微信
公众号

扫码关注公众号