Do not process empty lines or commented at Procfile

pull/128/head
Jorge Senín 2019-11-18 10:26:26 +01:00
rodzic 6f0468008a
commit 7a3f89cfa5
1 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -246,13 +246,17 @@ def parse_procfile(filename):
workers = {} workers = {}
if not exists(filename): if not exists(filename):
return None return None
with open(filename, 'r') as procfile: with open(filename, 'r') as procfile:
for line in procfile: for line_number, line in enumerate(procfile):
line = line.strip()
if line.startswith("#") or not line:
continue
try: try:
kind, command = map(lambda x: x.strip(), line.split(":", 1)) kind, command = map(lambda x: x.strip(), line.split(":", 1))
workers[kind] = command workers[kind] = command
except: except:
echo("Warning: unrecognized Procfile entry '{}'".format(line), fg='yellow') echo("Warning: unrecognized Procfile entry '{}' at line {}".format(line, line_number), fg='yellow')
if not len(workers): if not len(workers):
return {} return {}
# WSGI trumps regular web workers # WSGI trumps regular web workers