From 2a89a826608395134a15edc8d094b0267cc5f21c Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 19 Aug 2021 18:14:52 +0200 Subject: [PATCH] Add warning when trying to feed non-string values to Popen env --- moulinette/utils/process.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/moulinette/utils/process.py b/moulinette/utils/process.py index b8d5b915..32d220c8 100644 --- a/moulinette/utils/process.py +++ b/moulinette/utils/process.py @@ -2,6 +2,7 @@ import subprocess import os import threading import queue +import logging # This import is unused in this file. It will be deleted in future (W0611 PEP8), # but for the momment we keep it due to yunohost moulinette script that used @@ -12,7 +13,7 @@ quote # This line is here to avoid W0611 PEP8 error (see comments above) # Prevent to import subprocess only for common classes CalledProcessError = subprocess.CalledProcessError - +logger = logging.getLogger("moulinette.utils.process") # Alternative subprocess methods --------------------------------------- @@ -70,6 +71,9 @@ def call_async_output(args, callback, **kwargs): kwargs["env"] = os.environ kwargs["env"]["YNH_STDINFO"] = str(stdinfo.fdWrite) + if "env" in kwargs and not all(isinstance(v, str) for v in kwargs["env"].values()): + logger.warning("While trying to call call_async_output: env contained non-string values, probably gonna cause issue in Popen(...)") + try: p = subprocess.Popen(args, **kwargs)