Ticket #8686 (closed: fixed)

Opened 7 years ago

Last modified 5 years ago

Mantid return codes

Reported by: Peter Peterson Owned by: Peter Peterson
Priority: major Milestone: Release 3.1
Component: Framework Keywords:
Cc: Blocked By:
Blocking: Tester: Martyn Gigg

Description (last modified by Peter Peterson) (diff)

Currently mantid always returns 0 on exit. Change it so when something goes wrong it gives a different return code. A specific example is a python script which should never work under any conditions (fail.py):

blah

Executing this (in linux) and printing the result gives

MantidPlot -xq fail.py ; echo $?
ConfigService-[Information] This is Mantid version 3.0.20140108.1658 revision g5a8aa54
ConfigService-[Information] Properties file(s) loaded: /home/pf9/builds/mantid-release/bin/Mantid.properties, /home/pf9/.mantid/Mantid.user.properties
ConfigService-[Information] Logging to: /home/pf9/.mantid/mantid.log
FrameworkManager-[Notice] Welcome to Mantid version 3.0.20140108.1658 - Manipulation and Analysis Toolkit for Instrument Data
FrameworkManager-[Notice] Please cite Mantid in your publications using: http://dx.doi.org/10.5286/Software/Mantid
ConfigService-[Information] ParaView is available
MantidUI-[Notice] MantidPlot is shutting down...
0

which gives no indication that a failure happened. Running this same script through the python interpreter gives

python fail.py ; echo $?
Traceback (most recent call last):
  File "fail.py", line 1, in <module>
    blah
NameError: name 'blah' is not defined
1

Similarly a script (pass.py) should return 0:

import sys
sys.exit(0)

This ticket is to give more meaningful failure feedback when using the "-xq" flag on the command line.

Change History

comment:1 Changed 7 years ago by Peter Peterson

  • Status changed from new to inprogress

comment:2 Changed 7 years ago by Peter Peterson

Re #8686. Added real filename and line number when emitting errors.

Required a small refactor of the code. Hopefully the additional comments help out.

Changeset: 681a9955357ddf2cbc1d21b89191d0c70b2f1845

comment:3 Changed 7 years ago by Peter Peterson

Re #8686. Added error report to ApplicationWindow.

This was done by adding a slot for the error signal and turning it into a log message and exiting.

Changeset: dc73803856286089504a041046a439ede37a96a6

comment:4 Changed 7 years ago by Peter Peterson

  • Status changed from inprogress to verify
  • Resolution set to fixed
  • Tester set to Martyn Gigg

This is on feature/8686_mantidplot_returns.

To test: Try out the script in the ticket description and see that the desired behavior is there. Since this changes how python scripts are run make sure that the script window isn't broken.

comment:5 Changed 7 years ago by Martyn Gigg

  • Status changed from verify to verifying

comment:6 Changed 7 years ago by Peter Peterson

  • Description modified (diff)

comment:7 Changed 7 years ago by Peter Peterson

  • Status changed from verifying to reopened
  • Resolution fixed deleted

comment:8 Changed 7 years ago by Peter Peterson

  • Status changed from reopened to inprogress

Re #8686. Added check for PyErr_SystemExit for builds.

Changeset: 51a191cd1dc8f5379cc57fbb1cba0b7ce768697c

comment:9 Changed 7 years ago by Peter Peterson

  • Status changed from inprogress to verify
  • Resolution set to fixed

comment:10 Changed 7 years ago by Peter Peterson

Re #8686. Fixing bug found in testing.

Changeset: edc5a779d38645b02ecdeae18bab956430c46af3

comment:11 Changed 7 years ago by Martyn Gigg

  • Status changed from verify to closed

Merge remote-tracking branch 'origin/feature/8686_mantidplot_returns'

Full changeset: 41b48c2cc00b99f8d9f9d30052654955f140f6ef

comment:12 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 9530

Note: See TracTickets for help on using tickets.