Skip to content

Commit 5206721

Browse files
author
ekultek
committed
created a __reload functiont hat reloads the hosts from the host file, upped the length of the backup hosts file
1 parent e97e992 commit 5206721

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def backup_host_file(current, path):
161161
os.makedirs(path)
162162
new_filename = "{}/hosts_{}_{}.txt".format(
163163
path,
164-
lib.jsonize.random_file_name(length=17),
164+
lib.jsonize.random_file_name(length=22),
165165
str(datetime.datetime.today()).split(" ")[0]
166166
)
167167
shutil.copyfile(current, new_filename)

lib/term/terminal.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,12 @@ def __init__(self, tokens, modules):
6161
self.modules = modules
6262
try:
6363
self.loaded_hosts = open(lib.settings.HOST_FILE).readlines()
64-
except:
64+
except IOError:
6565
lib.output.warning("no hosts file present")
66-
self.loaded_hosts = []
66+
self.loaded_hosts = open(lib.settings.HOST_FILE, "a+").readlines()
67+
68+
def __reload(self):
69+
self.loaded_hosts = open(lib.settings.HOST_FILE).readlines()
6770

6871
def reflect_memory(self, max_memory=100):
6972
"""
@@ -551,6 +554,7 @@ def terminal_main_display(self, tokens, extra_commands=None, save_history=True):
551554
else:
552555
lib.output.error("cannot reset {} API credentials".format(choice))
553556
self.history.append(choice)
557+
self.__reload()
554558
except KeyboardInterrupt:
555559
lib.output.warning("use the `exit/quit` command to end terminal session")
556560
except IndexError:

0 commit comments

Comments
 (0)