From 7c09afef2e936938ae6f1465b7d925a3c61a49a1 Mon Sep 17 00:00:00 2001 From: Alexis Koralewski Date: Thu, 11 Mar 2021 13:16:42 +0100 Subject: [PATCH] fixing test with 'WITH_DOCKER' variable --- pyros.py | 5 ++--- src/core/pyros_django/pyros/settings.py | 9 +++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pyros.py b/pyros.py index 488d0be..c4e9f83 100755 --- a/pyros.py +++ b/pyros.py @@ -11,7 +11,7 @@ import signal import subprocess import sys import time - +import re @@ -128,8 +128,7 @@ try : except KeyError: WITH_DOCKER=False -# we can modify this test to be stronger (i.e match only "yes|Yes|y|Y") -if WITH_DOCKER is str and WITH_DOCKER.startswith("y") : +if type(WITH_DOCKER) is str and re.match("^y$|^Y$|^yes$|^Yes$",WITH_DOCKER.rstrip()) != None : WITH_DOCKER = True else : WITH_DOCKER = False diff --git a/src/core/pyros_django/pyros/settings.py b/src/core/pyros_django/pyros/settings.py index 4bfc04f..0323ce9 100644 --- a/src/core/pyros_django/pyros/settings.py +++ b/src/core/pyros_django/pyros/settings.py @@ -44,7 +44,7 @@ MODULES_VERSIONS = { -import os +import os,re # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) @@ -64,10 +64,15 @@ DEBUG = True # added 0.0.0.0, maybe try to map ip on docker -> search docker django runserver on localhost try: - WITH_DOCKER = os.environ.get('WITH_DOCKER') + WITH_DOCKER=os.environ['WITH_DOCKER'] except KeyError: WITH_DOCKER = False +if type(WITH_DOCKER) is str and re.match("^y$|^Y$|^yes$|^Yes$",WITH_DOCKER.rstrip()) != None : + WITH_DOCKER = True +else : + WITH_DOCKER = False + ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'pyros.irap.omp.eu'] if WITH_DOCKER: ALLOWED_HOSTS.append('0.0.0.0') -- libgit2 0.21.2