Skip to content

Commit

Permalink
Add some informational messages from CalcSoilSurfTemp
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoldmopar committed Sep 27, 2018
1 parent 9a92d91 commit 366ff65
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions workflows/calc_soil_surface_temp.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def main(self, run_directory, file_name, args):

csst_out = os.path.join(run_directory, 'CalcSoilSurfTemp.out')
if os.path.exists(csst_out):
self.callback("Removing previous output file")
os.remove(csst_out)

if os.path.exists(out_file_path):
Expand All @@ -76,8 +77,10 @@ def main(self, run_directory, file_name, args):
)

# run E+ and gather (for now fake) data
self.callback("Running CalcSoilSurfTemp!")
p1 = Popen([calc_soil_surf_temp_binary, file_name], stdout=PIPE, stdin=PIPE, cwd=run_directory)
p1.communicate(input=b'1\n1\n')
self.callback("CalcSoilSurfTemp Completed!")

if not os.path.exists(csst_out):
return EPLaunchWorkflowResponse1(
Expand All @@ -97,6 +100,7 @@ def main(self, run_directory, file_name, args):
os.remove(csst_out)

try:
self.callback("Processing output file...")
with open(out_file_path, 'r') as f:
lines = f.readlines()
avg_temp = float(lines[1][40:-1])
Expand All @@ -107,12 +111,14 @@ def main(self, run_directory, file_name, args):
ColumnNames.AmplitudeSurfTemp: amp_temp,
ColumnNames.PhaseConstant: phase_constant
}
self.callback(" ...DONE!")
return EPLaunchWorkflowResponse1(
success=True,
message="Ran EnergyPlus OK for file: %s!" % file_name,
column_data=column_data
)
except Exception: # noqa -- there could be lots of issues here, file existence, file contents, float conversion
self.callback(" ...FAILED!")
return EPLaunchWorkflowResponse1(
success=False,
message="CalcSoilSurfTemp seemed to run, but post processing failed for file: %s!" % full_file_path,
Expand Down

0 comments on commit 366ff65

Please sign in to comment.