From 03f75cf31f68424504c07e1bf3b0fccacfa4666e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geovanny=20Gonz=C3=A1lez-Rodr=C3=ADguez?= Date: Mon, 20 Jan 2025 16:34:11 +0100 Subject: [PATCH 1/2] Fix: Encode the output file properly for Python 2 runs Avoid compatibility errors with the `open(...)` function in Python 2 for setting the file's encoding. Sometimes in case an old architecture and `cms-sw` release is being used, a Python 2 interpreter is available for executing the `run_the_matrix_pdmv.py` module and there are compatibility issues with the encoding argument. --- core/utils/run_the_matrix_pdmv.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/utils/run_the_matrix_pdmv.py b/core/utils/run_the_matrix_pdmv.py index a1ec2eb..0b43cd2 100644 --- a/core/utils/run_the_matrix_pdmv.py +++ b/core/utils/run_the_matrix_pdmv.py @@ -4,6 +4,7 @@ from __future__ import print_function import argparse +import codecs import importlib import inspect import json @@ -312,7 +313,7 @@ def main(): print('All workflows:') print(json.dumps(workflows, indent=2, sort_keys=True)) if opt.output_file: - with open(opt.output_file, 'w', encoding='utf-8') as workflows_file: + with codecs.open(opt.output_file, 'w', encoding='utf-8') as workflows_file: json.dump(workflows, workflows_file) From 4a277d8ad240cbb0d6608b1f724f123c59b95cc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geovanny=20Gonz=C3=A1lez-Rodr=C3=ADguez?= Date: Mon, 20 Jan 2025 17:02:40 +0100 Subject: [PATCH 2/2] Fix: Compatibility issue with string formatting Remove the usage of f-strings. --- core/utils/dqm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/utils/dqm.py b/core/utils/dqm.py index f4da920..09e202a 100644 --- a/core/utils/dqm.py +++ b/core/utils/dqm.py @@ -33,7 +33,7 @@ def list_certification_files(cert_type): url = "%s/%s/" % (dqm_cert_url, cert_type) page_content = requests.get(url=url, timeout=30) if page_content.status_code != 200: - error_msg = f"Unable to retrieve the content related to {cert_type}" + error_msg = "Unable to retrieve the content related to %s" % cert_type raise HTTPError(error_msg, response=page_content) # Parse the HTML and retrieve the file names @@ -65,7 +65,7 @@ def get_certification_file(path): url = "%s/%s" % (dqm_cert_url, path) file = requests.get(url=url, timeout=30) if file.status_code != 200: - error_msg = f"Unable to retrieve the content related to {path}" + error_msg = "Unable to retrieve the content related to %s" % path raise HTTPError(error_msg, response=file) return file.json()