diff --git a/.github/workflows/pilotWrapper.yml b/.github/workflows/pilotWrapper.yml index 3c7bc9fe9de..3010db7c0b6 100644 --- a/.github/workflows/pilotWrapper.yml +++ b/.github/workflows/pilotWrapper.yml @@ -35,6 +35,7 @@ jobs: conda create -c conda-forge -c free -n python_${{ matrix.python }} python=${{ matrix.python }} - name: run pilot wrapper test run: | + export INVALID_UTF8_VAR=$'\xff' cp tests/Integration/WorkloadManagementSystem/Test_GenerateAndExecutePilotWrapper.py . eval "$(conda shell.bash hook)" && conda activate python_${{ matrix.python }} # use github APIs to get the artifacts URLS from https://github.com/DIRACGrid/Pilot/, for those named Pilot_${{ matrix.pilot_branch }} diff --git a/src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py b/src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py index 732d7360de3..cc2d14e45e8 100644 --- a/src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py +++ b/src/DIRAC/WorkloadManagementSystem/Utilities/PilotWrapper.py @@ -110,7 +110,15 @@ def formatTime(self, record, datefmt=None): # just logging the environment as first thing logger.debug('===========================================================') logger.debug('Environment of execution host\\n') -for key, val in os.environ.items(): +for key, val in getattr(os, "environb", os.environ).items(): + # Clean the environment of non-utf-8 characters + try: + key = key.decode("utf-8") + val = val.decode("utf-8") + except UnicodeDecodeError as e: + logger.error("Dropping %%s=%%s due to: %%s", key, val, e) + del os.environ[key] + continue logger.debug(key + '=' + val) logger.debug('===========================================================\\n')