1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-02-13 19:52:06 +00:00
iiab/roles/pylibs/templates/iiab_env.py.j2
2020-04-27 16:34:32 -05:00

27 lines
662 B
Django/Jinja

#!/usr/bin/python3
# read iiab.env from python
def get_iiab_env(name):
""" read iiab.env file for a value, return "" if does not exist"""
try:
fd = open("{{ iiab_env_file }}","r")
for line in fd:
line = line.lstrip()
line = line.rstrip('\n')
if len(line) == 0:
continue
if line[0] == "#":
continue
if line.find("=") == -1:
continue
chunks = line.split('=')
if chunks[0] == name:
return chunks[1]
return("")
except:
return("")
finally:
fd.close()
if __name__ == "__main__":
print(get_iiab_env("WWWROOT"))