Skip to content

Commit

Permalink
Check if file_script is not None
Browse files Browse the repository at this point in the history
  • Loading branch information
ghecko committed Sep 13, 2019
1 parent cf96180 commit dd8bed9
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions hydrabus_framework/core/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,18 @@ def run(self, file_script=None):
"""
session = PromptSession()
# This parts is used to automate test by passing file script
file_script = Path(file_script)
if file_script.is_file():
with file_script.open() as f:
commands = f.readlines()
for command in commands:
command = session.prompt(self.prompt, style=self.prompt_style, default=command.strip(), accept_default=True)
self.dispatcher.handle(self, command)
self.update_prompt()
else:
self.logger.handle("File does not exist or it is not a file", self.logger.ERROR)
if file_script is not None:
file_script = Path(file_script)
if file_script.is_file():
with file_script.open() as f:
commands = f.readlines()
for command in commands:
command = session.prompt(self.prompt, style=self.prompt_style, default=command.strip(),
accept_default=True)
self.dispatcher.handle(self, command)
self.update_prompt()
else:
self.logger.handle("File does not exist or it is not a file", self.logger.ERROR)
# Normal mode waiting for user_input
while True:
try:
Expand Down

0 comments on commit dd8bed9

Please sign in to comment.