mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/ocr.git
synced 2024-12-26 03:54:18 +00:00
Add wrapper and remove default arguments from Dockerfile
This commit is contained in:
parent
8a9ff27aaa
commit
f73a191314
@ -57,4 +57,3 @@ COPY hocrtotei /usr/local/bin
|
||||
COPY ocr /usr/local/bin
|
||||
|
||||
ENTRYPOINT ["ocr"]
|
||||
CMD ["--help"]
|
||||
|
31
wrapper/ocr
Executable file
31
wrapper/ocr
Executable file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
# coding=utf-8
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
|
||||
container_image = 'gitlab.ub.uni-bielefeld.de:4567/sfb1288inf/ocr:latest'
|
||||
|
||||
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, ocr_args = parser.parse_known_args()
|
||||
|
||||
if args.input_dir == None or args.output_dir == None:
|
||||
if args.input_dir != None:
|
||||
ocr_args.append('-i')
|
||||
ocr_args.append('/files_for_ocr')
|
||||
if args.output_dir != None:
|
||||
ocr_args.append('-o')
|
||||
ocr_args.append('/files_from_ocr')
|
||||
subprocess.run(['docker', 'run', '--rm', '-it', container_image] + ocr_args)
|
||||
else:
|
||||
subprocess.run(['docker', 'run', '--rm', '-it', '-v', args.input_dir + ':/files_for_ocr', '-v', args.output_dir + ':/files_from_ocr', container_image, '-i', '/files_for_ocr', '-o', '/files_from_ocr'] + ocr_args)
|
Loading…
Reference in New Issue
Block a user