Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parse_procfile(content, processes):
content = textwrap.dedent(content)
p = environ.parse_procfile(content)
assert p.processes == processes
def test_parse_procfile_ordered():
content = textwrap.dedent("""
one: onecommand
two: twocommand
three: twocommand
four: fourcommand
""")
p = environ.parse_procfile(content)
order = [k for k in p.processes]
assert order == ['one', 'two', 'three', 'four']
def run_command(info, host, port, procfile, process):
processes = None
if procfile:
for filename in ["Procfile.%s" % info.env, "Procfile"]:
if os.path.exists(filename):
click.echo("Using %s" % filename)
with open(filename) as f:
content = f.read()
processes = honcho.environ.parse_procfile(content).processes
break
if not processes:
processes = get_app_processes(info)
if process:
if process not in processes:
click.echo('Unknown process %s' % process)
sys.exit(1)
click.echo('Only running process %s' % process)
processes = dict([(process, processes[process])])
start_honcho(processes, {"HOST": host, "PORT": port})
def _procfile(filename):
try:
with open(filename) as f:
content = f.read()
except IOError:
raise CommandError('Procfile does not exist or is not a file')
try:
procfile = environ.parse_procfile(content)
except AssertionError as e:
raise CommandError(str(e))
return procfile