MCPcopy
hub / github.com/NullArray/AutoSploit / reflect_memory

Method reflect_memory

lib/term/terminal.py:79–106  ·  view source on GitHub ↗

reflect the command memory out of the history file

(self, max_memory=100)

Source from the content-addressed store, hash-verified

77 self.loaded_hosts = open(lib.settings.HOST_FILE).readlines()
78
79 def reflect_memory(self, max_memory=100):
80 """
81 reflect the command memory out of the history file
82 """
83 if os.path.exists(self.history_dir):
84 tmp = []
85 try:
86 with open(self.full_history_path) as history:
87 for item in history.readlines():
88 tmp.append(item.strip())
89 except:
90 pass
91 if len(tmp) == 0:
92 lib.output.warning("currently no history")
93 elif len(tmp) > max_memory:
94 import shutil
95
96 history_file_backup_path = "{}.{}.old".format(
97 self.full_history_path,
98 lib.jsonize.random_file_name(length=12)
99 )
100 shutil.copy(self.full_history_path, history_file_backup_path)
101 os.remove(self.full_history_path)
102 open(self.full_history_path, 'a+').close()
103 lib.output.misc_info("history file to large, backed up under '{}'".format(history_file_backup_path))
104 else:
105 for cmd in tmp:
106 self.history.append(cmd)
107
108 def do_display_history(self):
109 """

Callers 1

terminal_main_displayMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected