From 9b63ddfdb14fed1ead3a109107cf9512a08946a9 Mon Sep 17 00:00:00 2001 From: Stefan Marr Date: Thu, 9 Jan 2025 22:49:24 +0000 Subject: [PATCH] Preprocess command line arguments after parsing This removes unnecessary warnings about data reporting not possible without extra arguments when no execution or an execution plan was requested. Also warn about incompatible options. Signed-off-by: Stefan Marr --- rebench/output.py | 2 +- rebench/rebench.py | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/rebench/output.py b/rebench/output.py index 01f0eee7..7391ebbe 100644 --- a/rebench/output.py +++ b/rebench/output.py @@ -7,7 +7,7 @@ def output_as_str(string_like): class UIError(Exception): - def __init__(self, message, exception): + def __init__(self, message, exception = None): super(UIError, self).__init__() self._message = message self._exception = exception diff --git a/rebench/rebench.py b/rebench/rebench.py index b2ccc8ea..8980ac31 100755 --- a/rebench/rebench.py +++ b/rebench/rebench.py @@ -237,6 +237,19 @@ def _report_completion(self): success, _ = rebench_db.send_completion(get_current_time()) return success + @staticmethod + def _make_args_consistent(args): + if args.send_to_rebench_db and (args.no_execution or args.execution_plan): + raise UIError("Trying to send existing data with " + "--no-execution or --execution-plan set is not supported.\n") + + if args.no_execution or args.execution_plan: + # no execution, so no need to report data + args.use_data_reporting = False + + if args.no_execution and args.execution_plan: + raise UIError("Options --no-execution and --execution-plan are mutually exclusive.\n") + def run(self, argv=None): if argv is None: argv = sys.argv @@ -244,6 +257,7 @@ def run(self, argv=None): data_store = DataStore(self.ui) opt_parser = self.shell_options() args = opt_parser.parse_args(argv[1:]) + self._make_args_consistent(args) cli_reporter = CliReporter(args.verbose, self.ui)