2020-01-27 12:48:24 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# coding=utf-8
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
|
2020-02-07 15:26:24 +00:00
|
|
|
container_image = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/setup_files:latest'
|
2020-01-27 12:48:24 +00:00
|
|
|
container_input_dir = '/input'
|
|
|
|
container_output_dir = '/output'
|
|
|
|
uid = str(os.getuid())
|
|
|
|
gid = str(os.getgid())
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(add_help=False)
|
|
|
|
parser.add_argument(
|
|
|
|
'-i',
|
|
|
|
dest='input_dir',
|
|
|
|
required=False
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
'-o',
|
|
|
|
dest='output_dir',
|
|
|
|
required=False
|
|
|
|
)
|
|
|
|
args, remaining_args = parser.parse_known_args()
|
|
|
|
|
|
|
|
cmd = ['docker', 'run', '--rm', '-it', '-u', uid + ':' + gid]
|
|
|
|
if args.input_dir is not None:
|
|
|
|
host_input_dir = os.path.abspath(args.input_dir)
|
|
|
|
cmd += ['-v', host_input_dir + ':' + container_input_dir]
|
|
|
|
remaining_args += ['-i', container_input_dir]
|
|
|
|
if args.output_dir is not None:
|
|
|
|
host_output_dir = os.path.abspath(args.output_dir)
|
|
|
|
cmd += ['-v', host_output_dir + ':' + container_output_dir]
|
|
|
|
remaining_args += ['-o', container_output_dir]
|
|
|
|
cmd.append(container_image)
|
|
|
|
cmd += remaining_args
|
|
|
|
|
|
|
|
subprocess.run(cmd)
|