Skip to content

Commit

Permalink
When the selected S(Q) file is, by mistake, not an ASCII file, we wan…
Browse files Browse the repository at this point in the history
…t ADDIE continue to run (but does nothing) instead of crashing. (#311)

Co-authored-by: Zhang, Yuanpeng <[email protected]>
  • Loading branch information
Kvieta1990 and Zhang, Yuanpeng authored Nov 30, 2020
1 parent 29a506f commit ccfb4e0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
12 changes: 8 additions & 4 deletions addie/addiedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,14 @@ def load_sq(self, file_name):
InputWorkspace=sq_ws_name,
OutputWorkspace=sq_ws_name) # TODO REMOVE THIS LINE
elif ext == 'DAT' or ext == 'txt':
simpleapi.LoadAscii(
Filename=file_name,
OutputWorkspace=sq_ws_name,
Unit='MomentumTransfer')
try:
simpleapi.LoadAscii(
Filename=file_name,
OutputWorkspace=sq_ws_name,
Unit='MomentumTransfer')
except RuntimeError:
sq_ws_name, q_min, q_max = "InvalidInput", 0, 0
return sq_ws_name, q_min, q_max
# The S(Q) file is in fact S(Q)-1 in sq file. So need to add 1 to
# the workspace
out_ws = AnalysisDataService.retrieve(sq_ws_name)
Expand Down
2 changes: 2 additions & 0 deletions addie/calculate_gr/event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def load_sq(main_window):
sq_file_name = str(sq_file_name)
sq_ws_name, q_min, q_max = main_window._myController.load_sq(
sq_file_name)
if sq_ws_name == "InvalidInput" and q_min == 0 and q_max == 0:
return
# add to color management
color = main_window._pdfColorManager.add_sofq(sq_ws_name)

Expand Down

0 comments on commit ccfb4e0

Please sign in to comment.