mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/file-setup.git
synced 2024-12-27 20:04:17 +00:00
40 lines
1.0 KiB
Plaintext
40 lines
1.0 KiB
Plaintext
|
#!/usr/bin/env python3
|
||
|
# coding=utf-8
|
||
|
|
||
|
import argparse
|
||
|
import os
|
||
|
import subprocess
|
||
|
|
||
|
container_image = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/merge_images:latest'
|
||
|
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)
|