Skip to content
Snippets Groups Projects
Commit d1856132 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Additional command line options

For some reason, mantidworkbench did not have a `--version` option

Also added a command line option to convert warnings to exceptions. This
was used to squash various deprecation warnings that appear when using
newer versions of python libraries.
parent 39282bb9
No related branches found
No related tags found
No related merge requests found
...@@ -10,6 +10,7 @@ New and Improved ...@@ -10,6 +10,7 @@ New and Improved
- New plot interactions: Double click a legend to hide it, double click a curve to open it in the plot config dialog. - New plot interactions: Double click a legend to hide it, double click a curve to open it in the plot config dialog.
- It is now possible to overplot bin data from the matrix workspace view. - It is now possible to overplot bin data from the matrix workspace view.
- New command line options ``--version`` will print the version on mantid and exit. ``--error-on-warning`` will convert python warnings into exceptions. This is intended for developers so they can find deprecation warnings more easily.
- Improved the performance of the table workspace display for large datasets - Improved the performance of the table workspace display for large datasets
- A new empty facility with empty instrument is the default facility now, and - A new empty facility with empty instrument is the default facility now, and
user has to select their choice of facility (including ISIS) and instrument for the first time user has to select their choice of facility (including ISIS) and instrument for the first time
......
...@@ -7,12 +7,15 @@ ...@@ -7,12 +7,15 @@
# This file is part of the mantid workbench. # This file is part of the mantid workbench.
import argparse import argparse
import os import os
from mantid import __version__ as mtd_version
import warnings
def main(): def main():
# setup command line arguments # setup command line arguments
parser = argparse.ArgumentParser(description='Mantid Workbench') parser = argparse.ArgumentParser(description='Mantid Workbench')
parser.add_argument('script', nargs='?') parser.add_argument('script', nargs='?')
parser.add_argument('--version', action='version', version=mtd_version)
parser.add_argument('-x', parser.add_argument('-x',
'--execute', '--execute',
action='store_true', action='store_true',
...@@ -24,6 +27,10 @@ def main(): ...@@ -24,6 +27,10 @@ def main():
parser.add_argument('--profile', parser.add_argument('--profile',
action='store', action='store',
help='Run workbench with execution profiling. Specify a path for the output file.') help='Run workbench with execution profiling. Specify a path for the output file.')
parser.add_argument('--error-on-warning',
action='store_true',
help='Convert python warnings to exceptions')
try: try:
# set up bash completion as a soft dependency # set up bash completion as a soft dependency
import argcomplete import argcomplete
...@@ -34,6 +41,10 @@ def main(): ...@@ -34,6 +41,10 @@ def main():
# parse the command line options # parse the command line options
options = parser.parse_args() options = parser.parse_args()
if options.error_on_warning:
warnings.simplefilter("error") # Change the filter in this process
os.environ["PYTHONWARNINGS"] = "error" # Also affect subprocesses
if options.profile: if options.profile:
import cProfile import cProfile
output_path = os.path.abspath(os.path.expanduser(options.profile)) output_path = os.path.abspath(os.path.expanduser(options.profile))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment