Add simple check for empty values in secrets

This commit is contained in:
flyingscorpio@pinebookpro 2020-09-09 16:29:01 +02:00
parent 020a3b10c6
commit 0e1872aea5

View file

@ -46,15 +46,19 @@ class Installer:
with open("secrets", "r") as secrets_file: with open("secrets", "r") as secrets_file:
secrets = [ secrets = [
line.strip() line.strip()
for line in secrets_file.read() for line in secrets_file.readlines()
if not line.startswith("#") and line.strip() if not line.startswith("#") and line.strip()
] ]
except FileNotFoundError: except FileNotFoundError:
print("No 'secrets' file found. Did you forget to create it?") print("No 'secrets' file found. Did you forget to create it?")
sys.exit(1) sys.exit(1)
else: for line in secrets:
pass key, value = line.split("=")
# TODO: check the contents of the file value = value.replace("'", "").replace('"', "")
if not value:
print(line)
print(f" 'secrets' file has no value for {key}, please add one.")
sys.exit(1)
def define_os(self) -> str: def define_os(self) -> str:
"""Define what OS we are using.""" """Define what OS we are using."""