1
0
mirror of https://github.com/phusion/baseimage-docker.git synced 2026-03-25 20:07:55 +00:00

chore: remove all E501 updates

This commit is contained in:
Jose Diaz-Gonzalez
2017-05-08 17:41:25 -06:00
committed by GitHub
parent 263b582139
commit 7022d31858

View File

@@ -96,7 +96,7 @@ def import_envvars(clear_existing_environment=True, override_existing_environmen
if clear_existing_environment:
os.environ.clear()
for name, value in new_env.items():
if override_existing_environment or name not in os.environ:
if override_existing_environment or not name in os.environ:
os.environ[name] = value
@@ -132,10 +132,11 @@ def shquote(s):
def sanitize_shenvname(s):
return re.sub(SHENV_NAME_WHITELIST_REGEX, "_", s)
# Waits for the child process with the given PID, while at the same time
# reaping any other child processes that have exited (e.g. adopted child
# processes that have terminated).
def waitpid_reap_other_children(pid):
global terminated_child_processes
@@ -201,7 +202,7 @@ def run_command_killable(*argv):
pid = os.spawnvp(os.P_NOWAIT, filename, argv)
try:
status = waitpid_reap_other_children(pid)
except BaseException:
except BaseException as s:
warn("An error occurred. Aborting.")
stop_child_process(filename, pid)
raise
@@ -263,11 +264,8 @@ def run_startup_files():
def start_runit():
info("Booting runit daemon...")
pid = os.spawnl(os.P_NOWAIT,
"/usr/bin/runsvdir",
"/usr/bin/runsvdir",
"-P",
"/etc/service")
pid = os.spawnl(os.P_NOWAIT, "/usr/bin/runsvdir", "/usr/bin/runsvdir",
"-P", "/etc/service")
info("Runit started as PID %d" % pid)
return pid
@@ -334,9 +332,7 @@ def main(args):
info("Runit exited with status %d" % exit_status)
else:
info("Running %s..." % " ".join(args.main_command))
pid = os.spawnvp(os.P_NOWAIT,
args.main_command[0],
args.main_command)
pid = os.spawnvp(os.P_NOWAIT, args.main_command[0], args.main_command)
try:
exit_code = waitpid_reap_other_children(pid)
if exit_code is None:
@@ -348,7 +344,7 @@ def main(args):
except KeyboardInterrupt:
stop_child_process(args.main_command[0], pid)
raise
except BaseException:
except BaseException as s:
warn("An error occurred. Aborting.")
stop_child_process(args.main_command[0], pid)
raise
@@ -360,50 +356,25 @@ def main(args):
stop_child_process("runit daemon", runit_pid)
wait_for_runit_services()
# Parse options.
parser = argparse.ArgumentParser(description='Initialize the system.')
parser.add_argument(
'main_command',
metavar='MAIN_COMMAND',
type=str,
nargs='*',
help='The main command to run. (default: runit)')
parser.add_argument(
'--enable-insecure-key',
dest='enable_insecure_key',
action='store_const',
const=True,
default=False,
help='Install the insecure SSH key')
parser.add_argument(
'--skip-startup-files',
dest='skip_startup_files',
action='store_const',
const=True,
default=False,
help='Skip running /etc/my_init.d/* and /etc/rc.local')
parser.add_argument(
'--skip-runit',
dest='skip_runit',
action='store_const',
const=True,
default=False,
help='Do not run runit services')
parser.add_argument(
'--no-kill-all-on-exit',
dest='kill_all_on_exit',
action='store_const',
const=False,
default=True,
help='Do not kill all processes on the system upon exiting')
parser.add_argument(
'--quiet',
dest='log_level',
action='store_const',
const=LOG_LEVEL_WARN,
default=LOG_LEVEL_INFO,
help='Only print warnings and errors')
parser.add_argument('main_command', metavar='MAIN_COMMAND', type=str, nargs='*',
help='The main command to run. (default: runit)')
parser.add_argument('--enable-insecure-key', dest='enable_insecure_key',
action='store_const', const=True, default=False,
help='Install the insecure SSH key')
parser.add_argument('--skip-startup-files', dest='skip_startup_files',
action='store_const', const=True, default=False,
help='Skip running /etc/my_init.d/* and /etc/rc.local')
parser.add_argument('--skip-runit', dest='skip_runit',
action='store_const', const=True, default=False,
help='Do not run runit services')
parser.add_argument('--no-kill-all-on-exit', dest='kill_all_on_exit',
action='store_const', const=False, default=True,
help='Don\'t kill all processes on the system upon exiting')
parser.add_argument('--quiet', dest='log_level',
action='store_const', const=LOG_LEVEL_WARN, default=LOG_LEVEL_INFO,
help='Only print warnings and errors')
args = parser.parse_args()
log_level = args.log_level
@@ -412,12 +383,9 @@ if args.skip_runit and len(args.main_command) == 0:
sys.exit(1)
# Run main function.
signal.signal(signal.SIGTERM,
lambda signum, frame: ignore_signals_and_raise_keyboard_interrupt('SIGTERM'))
signal.signal(signal.SIGINT,
lambda signum, frame: ignore_signals_and_raise_keyboard_interrupt('SIGINT'))
signal.signal(signal.SIGALRM,
lambda signum, frame: raise_alarm_exception())
signal.signal(signal.SIGTERM, lambda signum, frame: ignore_signals_and_raise_keyboard_interrupt('SIGTERM'))
signal.signal(signal.SIGINT, lambda signum, frame: ignore_signals_and_raise_keyboard_interrupt('SIGINT'))
signal.signal(signal.SIGALRM, lambda signum, frame: raise_alarm_exception())
try:
main(args)
except KeyboardInterrupt: