Commit b86fdb9b authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Stop script execution if argument parsing fails

parent c280902d
Loading
Loading
Loading
Loading
+7 −0
Changes for src/scripts/filter_constants.py: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -49,8 +49,15 @@ except ImportError:
#
#  \returns result: `int` Exit code (0 = SUCCESS).
def main():
    config = {}
    result = 0
    try:
        config = parse_arguments()
    except ValueError as ex:
        print(ex)
        print("\nType \"filter_constants.py --help\" to get more detailed help.")
        result = 1
        exit(result)
    if config['version_mode']:
        print("filter_constants.py v%s."%__version__)
    elif (config['help_mode']):
+6 −0
Changes for src/scripts/guess_resources.py: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -43,7 +43,13 @@ number_reg = re.compile(r'[-+]?[0-9]+\.[0-9]+([eE][-+]?[0-9]+)?')
# \returns result: `int` Exit code (0 = SUCCESS).
def main():
    result = 0
    try:
        config = parse_arguments()
    except ValueError as ex:
        print(ex)
        print("\nType \"guess_resources.py --help\" to get more detailed help.")
        result = 1
        exit(result)
    if config['version_mode']:
        print("guess_resources.py v%s."%__version__)
    elif (config['help_mode']):
+1 −0
Changes for src/scripts/inertia.py: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ def main():
        print(ex)
        print("\nType \"./inertia.py --help\" to get more detailed help.")
        errors = 1
        exit(errors)
    if config['version_mode']:
      print("inertia.py v%s."%__version__)
    elif config['help_mode']:
+7 −0
Changes for src/scripts/model_maker.py: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -54,7 +54,14 @@ from sys import argv
# \returns result: `int` Exit code (0 = SUCCESS).
def main():
    result = 0
    config = {}
    try:
        config = parse_arguments()
    except ValueError as ex:
        print(ex)
        print("\nType \"./inertia.py --help\" to get more detailed help.")
        result = 1
        exit(result)
    if config['version_mode']:
        print("model_maker.py v%s."%__version__)
        exit(0)
+13 −2
Changes for src/scripts/parse_output.py: 13 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -29,6 +29,10 @@ import math
import pdb
from sys import argv

## \cond
__version__ = "0.10.10"
## \endcond

## \brief Main execution code
#
# `main()` is the function that handles the creation of the script configuration
@@ -45,7 +49,10 @@ def main():
        print(ex)
        print("\nType \"parse_output.py --help\" to get more detailed help.")
        errors = 1
    if config['help_mode']:
        exit(errors)
    if config['version_mode']:
        print("parse_output.py v%s."%__version__)
    elif config['help_mode']:
        config['help_mode'] = True
        print_help()
    else:
@@ -95,7 +102,8 @@ def parse_arguments():
        'application': '',
        'format': 'LEGACY',
        'selection': '[ALL]',
        'help_mode': False
        'help_mode': False,
        'version_mode': False
    }
    arg_index = 1
    skip_arg = False
@@ -120,6 +128,8 @@ def parse_arguments():
            config['selection'] = split_arg[1]
        elif (arg.startswith("--help")):
            config['help_mode'] = True
        elif (arg.startswith("--version")):
            config['version_mode'] = True
        else:
            raise ValueError("Unrecognized argument \'{0:s}\'".format(arg))
        arg_index += 1
@@ -841,6 +851,7 @@ def print_help():
    print("                         tions), IRP (i. e. Integrated Radiation Pressures), or DRP (i. e.")
    print("                         Differential Radiation Pressures)                                ")
    print("--help                   Print this help and exit.                                        ")
    print("--version                Print script version and exit.                                   ")
    print("                                                                                          ")

# ### PROGRAM EXECUTION ###
Loading