2019-05-21 12:29:26 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# coding=utf-8
|
|
|
|
|
2020-04-03 17:35:30 +02:00
|
|
|
from argparse import ArgumentParser
|
2019-06-03 13:32:42 +02:00
|
|
|
import os
|
2019-05-21 12:29:26 +02:00
|
|
|
import subprocess
|
|
|
|
|
2020-04-03 17:35:30 +02:00
|
|
|
CONTAINER_IMAGE = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/ocr:latest'
|
|
|
|
CONTAINER_INPUT_DIR = '/input'
|
|
|
|
CONTAINER_OUTPUT_DIR = '/output'
|
|
|
|
UID = str(os.getuid())
|
|
|
|
GID = str(os.getgid())
|
2019-05-21 12:29:26 +02:00
|
|
|
|
2020-04-03 17:35:30 +02:00
|
|
|
parser = ArgumentParser(add_help=False)
|
|
|
|
parser.add_argument('-i')
|
|
|
|
parser.add_argument('-o')
|
2019-06-03 13:32:42 +02:00
|
|
|
args, remaining_args = parser.parse_known_args()
|
2019-05-21 12:29:26 +02:00
|
|
|
|
2020-04-03 17:35:30 +02:00
|
|
|
cmd = ['docker', 'run', '--rm', '-it', '-u', '{}:{}'.format(UID, GID)]
|
|
|
|
if args.o is not None:
|
|
|
|
cmd += ['-v', '{}:{}'.format(os.path.abspath(args.o), CONTAINER_OUTPUT_DIR)]
|
|
|
|
remaining_args.insert(0, CONTAINER_OUTPUT_DIR)
|
|
|
|
if args.i is not None:
|
|
|
|
cmd += ['-v', '{}:{}'.format(os.path.abspath(args.i), CONTAINER_INPUT_DIR)]
|
|
|
|
remaining_args.insert(0, CONTAINER_INPUT_DIR)
|
|
|
|
cmd.append(CONTAINER_IMAGE)
|
2019-06-03 13:32:42 +02:00
|
|
|
cmd += remaining_args
|
2019-06-02 21:38:30 +02:00
|
|
|
|
|
|
|
subprocess.run(cmd)
|