Skip to content

Commit

Permalink
Add flag to run non-interactively
Browse files Browse the repository at this point in the history
This will run docker run in non-interactive mode.
  • Loading branch information
wallento committed May 13, 2021
1 parent ed7d266 commit c99594b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions edacontainerwrapper/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('--split-cwd-tail', type=int, default=RunArgumentsDefaults.split_cwd_tail)
parser.add_argument('--tool-version')
parser.add_argument('--non-interactive', action="store_true")
parser.add_argument('tool', choices=tools.keys())
parser.add_argument('toolargs', nargs='*')
args = parser.parse_args()
tool = args.tool
toolargs = args.toolargs
args = RunArguments(
split_cwd_tail = args.split_cwd_tail,
tool_version = args.tool_version if args.tool_version else tools[tool].default_version
tool_version = args.tool_version if args.tool_version else tools[tool].default_version,
interactive = not args.non_interactive
)
else:
tool = sys.argv[0]
args = RunArguments(split_cwd_tail=0)
args = RunArguments(split_cwd_tail=0, interactive=True)
toolargs = sys.argv[1:]

run(tool, args, toolargs)
Expand Down
6 changes: 3 additions & 3 deletions edacontainerwrapper/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from collections import namedtuple
import os

RunArguments = namedtuple("RunArguments", "split_cwd_tail tool_version")
RunArgumentsDefaults = RunArguments(split_cwd_tail=0, tool_version=None)
RunArguments = namedtuple("RunArguments", "split_cwd_tail tool_version interactive")
RunArgumentsDefaults = RunArguments(split_cwd_tail=0, tool_version=None, interactive=True)

def split_path(path, depth):
base = path
Expand Down Expand Up @@ -38,7 +38,7 @@ def run(toolname, args, toolargs):
root, tail = split_path(os.getcwd(), int(os.getenv("SPLIT_CWD_TAIL", args.split_cwd_tail)))
workdir = os.path.join(tool.projectpath, tail)

cmd = ["docker", "run", "-ti",
cmd = ["docker", "run", "-ti" if args.interactive else "",
"-v", f"{root}:{tool.projectpath}",
"-u", f"{os.getuid()}:{os.getgid()}",
"-w", f"{workdir}",
Expand Down

0 comments on commit c99594b

Please sign in to comment.