Skip to content

Commit

Permalink
refactor: improve error within data_access.execute_command
Browse files Browse the repository at this point in the history
  • Loading branch information
dmuldrew committed Dec 15, 2020
1 parent 23f1af3 commit a493053
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions powersimdata/data_access/csv_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ def _execute_and_check_err(self, command, err_message):
:return: (*str*) -- standard output stream.
"""
stdin, stdout, stderr = self.data_access.execute_command(command)
if len(stderr.readlines()) != 0:
raise IOError(err_message)
return stdout
command_output = str(stdout.readlines())
command_error = str(stderr.readlines())
if len(command_error) != 0:
raise IOError(err_message + "\n" + command_error)
return command_output
4 changes: 2 additions & 2 deletions powersimdata/data_access/scenario_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ def generate_scenario_id(self):
)

err_message = "Failed to generate id for new scenario"
stdout = self._execute_and_check_err(command, err_message)
scenario_id = stdout.readlines()[0].splitlines()[0]
command_output = self._execute_and_check_err(command, err_message)
scenario_id = command_output[0].splitlines()[0]
return scenario_id

def add_entry(self, scenario_info):
Expand Down

0 comments on commit a493053

Please sign in to comment.