From fa3e54a747d186795e4d72f0e1b2ba98f2da1eb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20M=C3=A5rtensson?= Date: Tue, 20 Nov 2018 14:57:28 +0100 Subject: [PATCH 1/2] change handling of verbosity argument --- examples/path_requests_run.py | 6 +++--- examples/transmission_main_example.py | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/examples/path_requests_run.py b/examples/path_requests_run.py index d7aa9cc4..b39c328d 100755 --- a/examples/path_requests_run.py +++ b/examples/path_requests_run.py @@ -40,8 +40,8 @@ parser = ArgumentParser(description = 'A function that computes performances for parser.add_argument('network_filename', nargs='?', type = Path, default= Path(__file__).parent / 'meshTopologyExampleV2.xls') parser.add_argument('service_filename', nargs='?', type = Path, default= Path(__file__).parent / 'meshTopologyExampleV2.xls') parser.add_argument('eqpt_filename', nargs='?', type = Path, default=Path(__file__).parent / 'eqpt_config.json') -parser.add_argument('-v', '--verbose', action='count') -parser.add_argument('-o', '--output', default=None) +parser.add_argument('-v', '--verbose', action='count', default=0) +parser.add_argument('-o', '--output') def requests_from_json(json_data,equipment): @@ -243,7 +243,7 @@ def path_result_json(pathresult): if __name__ == '__main__': args = parser.parse_args() - basicConfig(level={2: DEBUG, 1: INFO, 0: CRITICAL}.get(args.verbose, CRITICAL)) + basicConfig(level={2: DEBUG, 1: INFO, 0: CRITICAL}.get(args.verbose, DEBUG)) logger.info(f'Computing path requests {args.service_filename} into JSON format') # for debug # print( args.eqpt_filename) diff --git a/examples/transmission_main_example.py b/examples/transmission_main_example.py index f225e884..a24a199e 100755 --- a/examples/transmission_main_example.py +++ b/examples/transmission_main_example.py @@ -115,9 +115,9 @@ def main(network, equipment, source, destination, req = None): parser = ArgumentParser() parser.add_argument('-e', '--equipment', type=Path, default=Path(__file__).parent / 'eqpt_config.json') -parser.add_argument('-pl', '--plot', action='store_true', default=False) -parser.add_argument('-v', '--verbose', action='count') -parser.add_argument('-l', '--list-nodes', action='store_true', default=False, help='list all transceiver nodes') +parser.add_argument('-pl', '--plot', action='store_true') +parser.add_argument('-v', '--verbose', action='count', default=0) +parser.add_argument('-l', '--list-nodes', action='store_true', help='list all transceiver nodes') parser.add_argument('-po', '--power', default=0, help='channel ref power in dBm') #parser.add_argument('-plb', '--power-lower-bound', default=0, help='power sweep lower bound') #parser.add_argument('-pub', '--power-upper-bound', default=1, help='power sweep upper bound') @@ -129,7 +129,7 @@ parser.add_argument('destination', nargs='?', help='destination node') if __name__ == '__main__': args = parser.parse_args() - basicConfig(level={0: ERROR, 1: INFO, 2: DEBUG}.get(args.verbose, ERROR)) + basicConfig(level={0: ERROR, 1: INFO, 2: DEBUG}.get(args.verbose, DEBUG)) equipment = load_equipment(args.equipment) # logger.info(equipment) From 5efbd17829c1af6f147b46e61cfced5df9bfafb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20M=C3=A5rtensson?= Date: Tue, 20 Nov 2018 15:27:54 +0100 Subject: [PATCH 2/2] add help text --- examples/path_requests_run.py | 2 +- examples/transmission_main_example.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/path_requests_run.py b/examples/path_requests_run.py index b39c328d..8954fbb6 100755 --- a/examples/path_requests_run.py +++ b/examples/path_requests_run.py @@ -40,7 +40,7 @@ parser = ArgumentParser(description = 'A function that computes performances for parser.add_argument('network_filename', nargs='?', type = Path, default= Path(__file__).parent / 'meshTopologyExampleV2.xls') parser.add_argument('service_filename', nargs='?', type = Path, default= Path(__file__).parent / 'meshTopologyExampleV2.xls') parser.add_argument('eqpt_filename', nargs='?', type = Path, default=Path(__file__).parent / 'eqpt_config.json') -parser.add_argument('-v', '--verbose', action='count', default=0) +parser.add_argument('-v', '--verbose', action='count', default=0, help='increases verbosity for each occurence') parser.add_argument('-o', '--output') diff --git a/examples/transmission_main_example.py b/examples/transmission_main_example.py index a24a199e..42687de2 100755 --- a/examples/transmission_main_example.py +++ b/examples/transmission_main_example.py @@ -116,7 +116,7 @@ parser = ArgumentParser() parser.add_argument('-e', '--equipment', type=Path, default=Path(__file__).parent / 'eqpt_config.json') parser.add_argument('-pl', '--plot', action='store_true') -parser.add_argument('-v', '--verbose', action='count', default=0) +parser.add_argument('-v', '--verbose', action='count', default=0, help='increases verbosity for each occurence') parser.add_argument('-l', '--list-nodes', action='store_true', help='list all transceiver nodes') parser.add_argument('-po', '--power', default=0, help='channel ref power in dBm') #parser.add_argument('-plb', '--power-lower-bound', default=0, help='power sweep lower bound')