Skip to content

Commit

Permalink
Address issue gwpy#43, bad error message(s) for missing arguments we …
Browse files Browse the repository at this point in the history
…can't determine defaults for
  • Loading branch information
Joseph Areeda committed Sep 4, 2022
1 parent 1395e3a commit 358566e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
21 changes: 14 additions & 7 deletions omicron/cli/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def create_parser():
)
parser.add_argument(
'-f',
'--config-file',
'--config-file', default=const.OMICRON_CHANNELS_FILE,
help='path to configuration file',
)
parser.add_argument(
Expand Down Expand Up @@ -271,13 +271,20 @@ def main(args=None):
)

# -- parse configuration file and get parameters --------------------------

ifo = args.ifo
if ifo is None:
raise ValueError('IFO is unknown.')
if args.config_file is None:
config_file = const.OMICRON_PROD / f"{ifo}-channels.ini"
else:
config_file = args.config_file
config_file = Path(config_file)
if not config_file.exists():
raise IOError(f'Configuration file does not exist: {str(config_file.absolute())}')
cp = configparser.ConfigParser()
ok = cp.read(args.config_file)
if args.config_file not in ok:
raise IOError(
"Failed to read configuration file %r" % args.config_file,
)
ok = cp.read(config_file)
if str(config_file) not in ok:
raise IOError(f"Failed to read configuration file {str(config_file.absolute())}")
logger.info("Configuration read")

# validate
Expand Down
4 changes: 2 additions & 2 deletions omicron/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@

# omicron channel files
if ifo is not None:
OMICRON_GROUP_FILE = OMICRON_PROD / "{}-groups.txt".format(ifo)
OMICRON_CHANNELS_FILE = OMICRON_PROD, "{}-channels.txt".format(ifo)
OMICRON_GROUP_FILE = OMICRON_PROD / f"{ifo}-groups.txt"
OMICRON_CHANNELS_FILE = OMICRON_PROD / f"{ifo}-channels.ini"
else:
OMICRON_GROUP_FILE = None
OMICRON_CHANNELS_FILE = None

0 comments on commit 358566e

Please sign in to comment.