mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/file-setup.git
synced 2025-01-13 03:30:35 +00:00
Add wrapper script and fix path error
This commit is contained in:
parent
684a39ce49
commit
b0a0985c73
@ -19,5 +19,6 @@ RUN apt-get update \
|
|||||||
# Install merge_images
|
# Install merge_images
|
||||||
COPY merge_images /usr/local/bin
|
COPY merge_images /usr/local/bin
|
||||||
|
|
||||||
|
|
||||||
ENTRYPOINT ["merge_images"]
|
ENTRYPOINT ["merge_images"]
|
||||||
CMD ["--help"]
|
CMD ["--help"]
|
||||||
|
@ -24,7 +24,7 @@ def parse_arguments():
|
|||||||
|
|
||||||
def merge_images(input_dir, output_dir):
|
def merge_images(input_dir, output_dir):
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
os.makedirs(output_dir, exist_ok=True)
|
||||||
os.system('ls -v {i}/*.* >> {i}file_list.txt'.format(i=input_dir))
|
os.system('ls -v {i}/*.* >> {i}/file_list.txt'.format(i=input_dir))
|
||||||
os.system('convert @{i}/file_list.txt {o}/combined.tiff'.format(i=input_dir,
|
os.system('convert @{i}/file_list.txt {o}/combined.tiff'.format(i=input_dir,
|
||||||
o=output_dir))
|
o=output_dir))
|
||||||
|
|
||||||
|
39
wrapper/merge_images
Executable file
39
wrapper/merge_images
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/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)
|
Loading…
x
Reference in New Issue
Block a user