Move dotenv loading to get_var

This commit is contained in:
AaronDewes 2022-09-09 10:10:09 +00:00
parent 4741ea8edc
commit 03c4eaf058

View File

@ -81,6 +81,10 @@ def getArguments():
return arguments
def get_var(var_name):
if os.path.isfile(dotCitadelPath):
dotenv=parse_dotenv(os.path.join(nodeRoot, "..", ".env"))
else:
dotenv=parse_dotenv(os.path.join(nodeRoot, ".env"))
if var_name in dotenv:
return str(dotenv[var_name])
else:
@ -106,10 +110,6 @@ def handleAppV4(app):
yaml.dump(resultYml["spec"], dockerComposeFile)
torDaemons = ["torrc-apps", "torrc-apps-2", "torrc-apps-3"]
torFileToAppend = torDaemons[random.randint(0, len(torDaemons) - 1)]
if os.path.isfile(dotCitadelPath):
dotenv=parse_dotenv(os.path.join(nodeRoot, "..", ".env"))
else:
dotenv=parse_dotenv(os.path.join(nodeRoot, ".env"))
with open(os.path.join(nodeRoot, "tor", torFileToAppend), 'a') as f:
f.write(replace_vars(resultYml["new_tor_entries"]))
mainPort = resultYml["port"]