Skip to content

Commit

Permalink
handle undefined environment variables with a warning and empty subst…
Browse files Browse the repository at this point in the history
…itute #67
  • Loading branch information
proycon committed Mar 15, 2018
1 parent af1f4aa commit 400b77b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion clam/common/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2483,10 +2483,13 @@ def loadconfig(callername, required=True):
for key, value in data.items():
#replace variables
if '{' in value:
variables = re.findall("\{\{\w+\}\}")
variables = re.findall(r"\{\{\w+\}\}")
for v in variables:
if v.strip('{}') in os.environ:
value = value.replace(v,os.environ[v.strip('{}')])
else:
print("Undefined environment variable in " + configfile + ": " + v.strip('{}'),file=sys.stderr)
value = value.replace(v,"")
setattr(settingsmodule,key.upper(), value)
return True

Expand Down

0 comments on commit 400b77b

Please sign in to comment.