From d3021e79efa7b9f91e8685f5dfdaacb59ad2edcc Mon Sep 17 00:00:00 2001 From: "Mads M. Pedersen" <mmpe@dtu.dk> Date: Thu, 12 Jan 2017 15:55:18 +0100 Subject: [PATCH] improved error messages in hawc2 simulation --- wetb/hawc2/ascii2bin/make_exe.py | 4 ++-- wetb/hawc2/htc_file.py | 14 +++++++++++--- wetb/hawc2/simulation.py | 5 +++-- wetb/utils/cluster_tools/ssh_client.py | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/wetb/hawc2/ascii2bin/make_exe.py b/wetb/hawc2/ascii2bin/make_exe.py index 8b1e848..8a1682a 100644 --- a/wetb/hawc2/ascii2bin/make_exe.py +++ b/wetb/hawc2/ascii2bin/make_exe.py @@ -9,6 +9,6 @@ standard_library.install_aliases() if __name__=="__main__": - from build_exe.cx.build_cx_exe import NUMPY - from build_exe.cx import build_cx_exe + from mmpe.build_exe.cx.build_cx_exe import NUMPY + from mmpe.build_exe.cx import build_cx_exe build_cx_exe.build_exe("ascii2bin.py", version="3.0.1", includes=["'pandas'"], modules=['email', NUMPY]) diff --git a/wetb/hawc2/htc_file.py b/wetb/hawc2/htc_file.py index 9c4761b..fc51e07 100644 --- a/wetb/hawc2/htc_file.py +++ b/wetb/hawc2/htc_file.py @@ -43,13 +43,21 @@ class HTCFile(HTCContents, HTCDefaults): modelpath = "../" initial_comments = None _contents = None - def __init__(self, filename=None, relative_modelpath="../"): + def __init__(self, filename=None, modelpath="../"): + """ + Parameters + --------- + filename : str + Absolute filename of htc file + modelpath : str + Model path relative to htc file + """ if filename is not None: - self.modelpath = os.path.realpath(os.path.join(os.path.dirname(filename), relative_modelpath)) + self.modelpath = os.path.realpath(os.path.join(os.path.dirname(filename), modelpath)) self.filename = filename else: - self.modelpath = relative_modelpath + self.modelpath = modelpath diff --git a/wetb/hawc2/simulation.py b/wetb/hawc2/simulation.py index 8e96c04..eca748c 100755 --- a/wetb/hawc2/simulation.py +++ b/wetb/hawc2/simulation.py @@ -339,9 +339,10 @@ class Simulation(object): except: print ("finish_simulation failed", str(self)) raise - except: + except Exception as e: self.status = ERROR - raise + self.errors.append(str(e)) + raise e finally: self.is_done = True diff --git a/wetb/utils/cluster_tools/ssh_client.py b/wetb/utils/cluster_tools/ssh_client.py index bd5450d..39d2f7c 100644 --- a/wetb/utils/cluster_tools/ssh_client.py +++ b/wetb/utils/cluster_tools/ssh_client.py @@ -51,7 +51,7 @@ class SSHClient(object): def connect(self): if self.password is None or self.password == "": - raise IOError("Password not set") + raise IOError("Password not set for %s"%self.host) self.client = paramiko.SSHClient() self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self.client.connect(self.host, self.port, username=self.username, password=self.password, pkey=self.key, timeout=self.TIMEOUT) -- GitLab