From 12dca6c778485ce6f42e9c4e4c5fc97ae8b58970 Mon Sep 17 00:00:00 2001 From: mj Date: Wed, 12 Jan 2022 14:03:11 +0100 Subject: [PATCH] Changed order of arguments for query script --- tests/query_device.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/tests/query_device.py b/tests/query_device.py index 8ce3528..5eb2834 100755 --- a/tests/query_device.py +++ b/tests/query_device.py @@ -60,18 +60,20 @@ while arg_index < len(argv): continue elif not action: action = argv[arg_index] - elif action == 'write' and value == None: - try: - value = int(argv[arg_index]) - except ValueError: - print(f'Wrong format for argument "value"') - exit(-3) else: - # rest of the arguments should be register numbers/names - try: - register_number.append(int(argv[arg_index])) - except ValueError: - register_name.append(argv[arg_index]) + # if action is write, last argument should be value + if action == 'write' and arg_index == len(argv) - 1: + try: + value = int(argv[arg_index]) + except ValueError: + print(f'Wrong format for argument "value"') + exit(-3) + else: + # rest of the arguments should be register numbers/names + try: + register_number.append(int(argv[arg_index])) + except ValueError: + register_name.append(argv[arg_index]) arg_index += 1