From 894037909cff3687b8825a777c25cf0631002df3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mois=C3=A9s=20Guimar=C3=A3es=20de=20Medeiros?= Date: Wed, 2 Dec 2020 15:07:11 +0100 Subject: [PATCH] Use default value when fetching prefix+ '_URL' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a driver does not register an environment variable sufixed with _URL, pifpaf will break having None when it expets a string. Signed-off-by: Moisés Guimarães de Medeiros --- pifpaf/__main__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pifpaf/__main__.py b/pifpaf/__main__.py index 4859627..3e00e28 100644 --- a/pifpaf/__main__.py +++ b/pifpaf/__main__.py @@ -185,7 +185,7 @@ def expand_urls_var(url): putenv("PID", str(os.getpid())) putenv("DAEMON", daemon) - url = os.getenv(driver.env_prefix + "_URL") + url = os.getenv(driver.env_prefix + "_URL", "") putenv("%s_URL" % daemon.upper(), url) os.putenv(global_urls_variable, expand_urls_var(url)) @@ -251,7 +251,7 @@ def _cleanup(signum, frame): signal.signal(signal.SIGPIPE, signal.SIG_IGN) signal.pause() else: - url = driver.env['%s_URL' % driver.env_prefix] + url = driver.env.get('%s_URL' % driver.env_prefix, "") driver.env.update({ "PIFPAF_PID": pid, env_prefix + "_PID": pid,