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_start_returncode():
procfile = 'Procfile.returncodewin' if compat.ON_WINDOWS else 'Procfile.returncode'
ret, out, err = get_honcho_output(['-f', procfile, 'start'])
assert_true(ret in [123, 42])
def test_supervisord_export():
procfile = get_procfile("Procfile.simple")
render = get_render(procfile, DEFAULT_OPTIONS, DEFAULT_ENV, DEFAULT_CONCURRENCY)
assert_equal(1, len(render))
(fname, contents), = render
parser = compat.ConfigParser()
parser.readfp(compat.StringIO(contents))
section = "program:app-foo"
assert_true(parser.has_section(section))
assert_equal(DEFAULT_OPTIONS.user, parser.get(section, "user"))
assert_equal("{0} -c 'python simple.py'".format(DEFAULT_OPTIONS.shell), parser.get(section, "command"))
def test_start_returncode():
procfile = 'Procfile.returncodewin' if compat.ON_WINDOWS else 'Procfile.returncode'
ret, out, err = get_honcho_output(['-f', procfile, 'start'])
assert_true(ret in [123, 42])
def test_proctype_increment():
procfile = 'Procfile.portswin' if compat.ON_WINDOWS else 'Procfile.ports'
ret, out, err = get_honcho_output(['-f', procfile, 'start'])
assert_equal(ret, 0)
assert_regexp_matches(out, r'web\.1 \| (....)?PORT=5000')
assert_regexp_matches(out, r'worker\.1 \| (....)?PORT=5100')
assert_regexp_matches(out, r'redis\.1 \| (....)?PORT=5200')
assert_regexp_matches(out, r'es\.1 \| (....)?PORT=5300')
def command_run(args):
os.environ.update(_read_env(args.app_root, args.env))
argv = args.argv
# If the first of the remaining args is '--', skip it.
if argv and argv[0] == '--':
argv = argv[1:]
if compat.ON_WINDOWS:
# do not quote on Windows, subprocess will handle it for us
# using the MSFT quoting rules
cmd = argv
else:
cmd = ' '.join(compat.shellquote(arg) for arg in argv)
p = Popen(cmd, stdout=sys.stdout, stderr=sys.stderr,
start_new_session=False)
signal.signal(signal.SIGINT, signal.SIG_IGN)
p.wait()
sys.exit(p.returncode)
if compat.ON_WINDOWS:
def terminate(self, pid):
# The first argument to OpenProcess represents the desired access
# to the process. 1 represents the PROCESS_TERMINATE access right.
handle = ctypes.windll.kernel32.OpenProcess(1, False, pid)
ctypes.windll.kernel32.TerminateProcess(handle, -1)
ctypes.windll.kernel32.CloseHandle(handle)
else:
def terminate(self, pid):
try:
os.killpg(pid, signal.SIGTERM)
except OSError as e:
if e.errno not in [errno.EPERM, errno.ESRCH]:
raise
if compat.ON_WINDOWS:
def kill(self, pid):
# There's no SIGKILL on Win32...
self.terminate(pid)
else:
def kill(self, pid):
try:
os.killpg(pid, signal.SIGKILL)
except OSError as e:
if e.errno not in [errno.EPERM, errno.ESRCH]:
raise
class Procfile(object):
"""A data structure representing a Procfile"""
def __init__(self):