From a49305389998ca0c2b4419957028d7bcded1fa26 Mon Sep 17 00:00:00 2001 From: Daniel Muldrew Date: Mon, 14 Dec 2020 16:44:03 -0800 Subject: [PATCH] refactor: improve error within data_access.execute_command --- powersimdata/data_access/csv_store.py | 8 +++++--- powersimdata/data_access/scenario_list.py | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/powersimdata/data_access/csv_store.py b/powersimdata/data_access/csv_store.py index 02ec0ed36..46585d21d 100644 --- a/powersimdata/data_access/csv_store.py +++ b/powersimdata/data_access/csv_store.py @@ -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 diff --git a/powersimdata/data_access/scenario_list.py b/powersimdata/data_access/scenario_list.py index f032f6b43..b5a79d766 100644 --- a/powersimdata/data_access/scenario_list.py +++ b/powersimdata/data_access/scenario_list.py @@ -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):