Decouple argument parser from sys.argv

This commit is contained in:
Jose Gracia 2023-11-22 14:35:19 +01:00
parent 3843ce1350
commit 6ff52227ef

View file

@ -4,7 +4,7 @@ from collections import OrderedDict
import os.path
def parse_arguments():
def parse_arguments(args):
parser = argparse.ArgumentParser(
description='Produce detailed power usage data for a list of jobids.')
parser.add_argument('-v', '--verbose', action='store_true',
@ -13,7 +13,7 @@ def parse_arguments():
nargs='+',
help='Job ID such as "2260215" or "2260215.hawk-pbs5"')
return parser.parse_args()
return parser.parse_args(args)
def parse_jobid(s):
import re
@ -204,8 +204,8 @@ class App:
if __name__ == "__main__":
config = parse_arguments()
config.interval = 5
import sys
config = parse_arguments(sys.argv[1:])
main = App(config)
main.run_all()