From fa4fe251b4dd7826c58d3ca7900b1a391907ec9c Mon Sep 17 00:00:00 2001 From: Clint Lawrence Date: Tue, 23 Jul 2024 15:34:29 +1000 Subject: [PATCH 1/2] Add cli argument for diagnostic log location --- src/fixate/__main__.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/fixate/__main__.py b/src/fixate/__main__.py index d75433a..eb5ea77 100644 --- a/src/fixate/__main__.py +++ b/src/fixate/__main__.py @@ -8,6 +8,7 @@ from importlib.machinery import SourceFileLoader from zipimport import zipimporter from pubsub import pub +from pathlib import Path import fixate.config from fixate.core.exceptions import SequenceAbort from fixate.core.ui import user_info_important, user_serial, user_ok @@ -118,9 +119,16 @@ def get_parser(): action="store_true", help="The sequencer will not prompt for retries.", ) - parser.add_argument( + diagnostic_group = parser.add_mutually_exclusive_group() + diagnostic_group.add_argument( "--disable-logs", action="store_true", help="Turn off diagnostic logs" ) + diagnostic_group.add_argument( + "--diagnostic-log-dir", + default=fixate.config.LOG_DIRECTORY, + type=Path, + help="Directory to store the diagnostic log", + ) return parser @@ -399,10 +407,10 @@ def run_main_program(test_script_path=None, main_args=None): parser = get_parser() args, unknown = parser.parse_known_args(args=main_args) if not args.disable_logs: - fixate.config.LOG_DIRECTORY.mkdir(parents=True, exist_ok=True) + args.diagnostic_log_dir.mkdir(parents=True, exist_ok=True) handler = RotateEachInstanceHandler( - fixate.config.LOG_DIRECTORY / "fixate.log", backupCount=10 + args.diagnostic_log_dir / "fixate.log", backupCount=10 ) handler.setFormatter( logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s") From 9daa000b731adb0ab62f93017e2ea8211759cc7b Mon Sep 17 00:00:00 2001 From: Clint Lawrence Date: Tue, 23 Jul 2024 15:35:02 +1000 Subject: [PATCH 2/2] Either script path or zip file is required --- src/fixate/__main__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fixate/__main__.py b/src/fixate/__main__.py index eb5ea77..f446c2c 100644 --- a/src/fixate/__main__.py +++ b/src/fixate/__main__.py @@ -39,14 +39,14 @@ def get_parser(): ) # Optional Arguments - mutex_group = parser.add_mutually_exclusive_group() - mutex_group.add_argument( + script_group = parser.add_mutually_exclusive_group(required=True) + script_group.add_argument( "-p", "--path", help="""Path to the directory where the script file is located. This is mutually exclusive with --zip""", ) - mutex_group.add_argument( + script_group.add_argument( "-z", "--zip", help="""Path to zip file of test scripts. Mutually exclusive with --path""",