Commit 7c09afef2e936938ae6f1465b7d925a3c61a49a1

Authored by Alexis Koralewski
1 parent b183b691
Exists in dev

fixing test with 'WITH_DOCKER' variable

Showing 2 changed files with 9 additions and 5 deletions   Show diff stats
pyros.py
... ... @@ -11,7 +11,7 @@ import signal
11 11 import subprocess
12 12 import sys
13 13 import time
14   -
  14 +import re
15 15  
16 16  
17 17  
... ... @@ -128,8 +128,7 @@ try :
128 128 except KeyError:
129 129 WITH_DOCKER=False
130 130  
131   -# we can modify this test to be stronger (i.e match only "yes|Yes|y|Y")
132   -if WITH_DOCKER is str and WITH_DOCKER.startswith("y") :
  131 +if type(WITH_DOCKER) is str and re.match("^y$|^Y$|^yes$|^Yes$",WITH_DOCKER.rstrip()) != None :
133 132 WITH_DOCKER = True
134 133 else :
135 134 WITH_DOCKER = False
... ...
src/core/pyros_django/pyros/settings.py
... ... @@ -44,7 +44,7 @@ MODULES_VERSIONS = {
44 44  
45 45  
46 46  
47   -import os
  47 +import os,re
48 48  
49 49 # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
50 50 BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
... ... @@ -64,10 +64,15 @@ DEBUG = True
64 64  
65 65 # added 0.0.0.0, maybe try to map ip on docker -> search docker django runserver on localhost
66 66 try:
67   - WITH_DOCKER = os.environ.get('WITH_DOCKER')
  67 + WITH_DOCKER=os.environ['WITH_DOCKER']
68 68 except KeyError:
69 69 WITH_DOCKER = False
70 70  
  71 +if type(WITH_DOCKER) is str and re.match("^y$|^Y$|^yes$|^Yes$",WITH_DOCKER.rstrip()) != None :
  72 + WITH_DOCKER = True
  73 +else :
  74 + WITH_DOCKER = False
  75 +
71 76 ALLOWED_HOSTS = ['localhost', '127.0.0.1', 'pyros.irap.omp.eu']
72 77 if WITH_DOCKER:
73 78 ALLOWED_HOSTS.append('0.0.0.0')
... ...