Compare commits

..

No commits in common. "556b9d6b754731dbd51cd40e2915ff7a2f9b75e1" and "84aaf451f7f3ed2aabf62616331b65ff7cb5cf96" have entirely different histories.

View File

@ -80,9 +80,8 @@ def docker_create_user (container, user, uid=None):
def docker_start (container):
call(["docker", "start", container])
def docker_exec (container, command, user, env={}, tty=True, work_dir=None):
call(["docker", "exec", "--user", user] + \
(["-ti" if tty else "-i"]) + \
def docker_exec (container, command, user, env={}, work_dir=None):
call(["docker", "exec", "--user", user, "-ti"] + \
(["--workdir", work_dir] if work_dir else []) + \
list(chain.from_iterable([["--env", f"{kv[0]}={kv[1]}"] for kv in env.items()])) + \
[container] + command)
@ -132,14 +131,13 @@ def expand_user_volumes (volumes):
return mappings
def find_config_files (config_names):
def find_config_files (config_name):
config_files = []
directory = os.path.abspath(os.getcwd())
while True:
for config_name in config_names:
config_file = os.path.join(directory, config_name)
if os.path.exists(config_file):
config_files.append(config_file)
config_file = os.path.join(directory, config_name)
if os.path.exists(config_file):
config_files.append(config_file)
if directory == "/" or (not directory):
break
@ -176,7 +174,6 @@ command_env = {}
command_workdir = None
quiet = False
tty = sys.stdout.isatty()
# load config from files
config = load_config_files({
@ -191,9 +188,8 @@ config = load_config_files({
"user_volumes": user_volumes,
"pull": pull,
"command_env": command_env,
"cwd": os.getcwd(),
"tty": tty
}, find_config_files([OTHERWORLD_CONFIG, "{}{}".format(container_name, OTHERWORLD_CONFIG)]))
"cwd": os.getcwd()
}, find_config_files(OTHERWORLD_CONFIG))
locals().update(config)
while len(command) > 0:
@ -201,9 +197,6 @@ while len(command) > 0:
if arg == "--quiet":
command = command[1:]
quiet = True
elif arg == "--notty":
command = command[1:]
tty = False
elif arg == "--rm":
actions.append("rm")
command = command[1:]
@ -320,4 +313,4 @@ except Exception:
if not quiet:
print(f">> Welcome to {container_name} (IP {container['NetworkSettings']['IPAddress']})")
docker_exec(container_name, command, command_user, command_env, tty, command_workdir)
docker_exec(container_name, command, command_user, command_env, command_workdir)