ocr/wrapper/ocr

30 lines
881 B
Plaintext
Raw Normal View History

#!/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
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())
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()
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)