From bd16f64bdc3e74494b6642adaffc18834f940dad Mon Sep 17 00:00:00 2001 From: Tristan Pinsonneault-Marotte Date: Fri, 20 Sep 2024 09:52:46 -0700 Subject: [PATCH 1/2] feat(core.server_scripts.Common): Set log level and format. --- python/pysmurf/core/server_scripts/Common.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/python/pysmurf/core/server_scripts/Common.py b/python/pysmurf/core/server_scripts/Common.py index c60eec4c5..a214d3194 100755 --- a/python/pysmurf/core/server_scripts/Common.py +++ b/python/pysmurf/core/server_scripts/Common.py @@ -23,6 +23,7 @@ import subprocess import sys import zipfile +import logging import pyrogue @@ -48,6 +49,16 @@ def process_args(args): if it was not defined. """ + # Setup logging + logger = logging.getLogger() + logger.setLevel(args.log_level) + # set up a handler with timestamps + handler = logging.StreamHandler() + handler.setLevel(args.log_level) + formatter = logging.Formatter("[%(asctime)s] %(levelname)s:%(name)s: %(msg)s") + handler.setFormatter(formatter) + logger.addHandler(handler) + # Verify if the zip file was specified if args.zip_file: zip_file_name = args.zip_file @@ -204,5 +215,9 @@ def make_parser(parser=None): group.add_argument('--use-qt', action='store_true', dest='use_qt', default=False, help="Use the QT ." ) + group.add_argument('--log-level', type=str.upper, help="Set the logging level.", + choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"], + default="WARNING" + ) return parser From 90d65f384bb260f5f4b1a8b98b00a9a47a5b19fa Mon Sep 17 00:00:00 2001 From: Tristan Pinsonneault-Marotte Date: Fri, 20 Sep 2024 14:45:30 -0700 Subject: [PATCH 2/2] style: satisfy flake8 CI --- python/pysmurf/client/base/smurf_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/pysmurf/client/base/smurf_config.py b/python/pysmurf/client/base/smurf_config.py index 65a73bb30..9f50a2e89 100644 --- a/python/pysmurf/client/base/smurf_config.py +++ b/python/pysmurf/client/base/smurf_config.py @@ -442,7 +442,7 @@ def validate_config(loaded_config): # data_out_mux Optional("data_out_mux", - default=default_data_out_mux_dict[band]) : \ + default=default_data_out_mux_dict[band]) : And([Use(int)], list, lambda l: len(l) == 2 and l[0] != l[1] and all(0 <= ll <= 9 for ll in l)),