Skip to content
Snippets Groups Projects

Convert scripts to entry_points

Open Duncan Macleod requested to merge duncanmmacleod/dqsegdb-client:entry-points into master
1 unresolved thread
Files
3
#!/usr/bin/env python3
# Copyright (C) 2014-2020 Syracuse University, European Gravitational Observatory, and Christopher Newport University. Written by Ryan Fisher and Gary Hemming. See the NOTICE file distributed with this work for additional information regarding copyright ownership.
#
# This program is free software: you can redistribute it and/or modify
@@ -49,7 +48,7 @@ import json
from six.moves.urllib.parse import urlparse
PROGRAM_NAME = sys.argv[0].replace('./','')
PROGRAM_NAME = f"{__spec__.name.rsplit('.', 1)[-1]}_dqsegdb"
PROGRAM_PID = os.getpid()
try:
@@ -77,7 +76,7 @@ __verbose_msg__ = "version: " + get_versions()['version'] + "\nfull-revisionid:
#
def parse_command_line():
def parse_command_line(args=None):
"""
Parse the command line, return an options object
"""
@@ -86,7 +85,8 @@ def parse_command_line():
version = "Name: %prog\n" + __verbose_msg__,
#version = "Name: %%prog\nVersion: %s" % get_versions()['version'],
usage = "%prog [ --version | --segment-url ] options gps-time1",
description = "Provides a report of known and active flags from the segment database for a given GPS time, with a configurable window."
description = "Provides a report of known and active flags from the segment database for a given GPS time, with a configurable window.",
prog = PROGRAM_NAME,
)
@@ -106,7 +106,7 @@ def parse_command_line():
parser.add_option("-f", "--tom-formatting", action = "store_true", help = "Tom Dent requested formatting option: condensed output into single lines.")
parser.add_option("-b", "--seperate-good-from-bad", action = "store_true", help = "Seperates flags marked by the database as being active when the ifo is in a bad state from those that are active when the ifo is in a good state.")
options, time = parser.parse_args()
options, time = parser.parse_args(args=args)
# Make sure we have required arguments
if options.segment_url:
@@ -291,8 +291,9 @@ def get_full_name(ifo, name, version):
# =============================================================================
#
if __name__ == '__main__':
options, database_location, time = parse_command_line()
def main(args=None):
options, database_location, time = parse_command_line(args=args)
o=urlparse(options.segment_url)
protocol=o.scheme
@@ -474,4 +475,5 @@ if __name__ == '__main__':
fh.close()
if __name__ == "__main__":
sys.exit(main())
Loading