Skip to content
Permalink
a6b0d41fcc
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
executable file 103 lines (85 sloc) 2.21 KB
#!/usr/bin/env python3
from utils.settings import BASE_DIR, load_config, create_docker_env_file
from utils.functions import exec_in_container, run
from pathlib import Path
import shlex
import shutil
import pwd
import os
import subprocess
from time import sleep
BASE_DIR = Path( __file__ ).parent.parent
DEP_DIR = BASE_DIR / "dependencies"
SQLDB_WAIT_TIME=20
def create_dir(dir):
print( "creating dir '{}'".format( dir ) )
Path(dir).mkdir(
parents = True,
exist_ok = True
)
def copy_dir(src, dst):
print( "'{}' -> '{}'".format( src, dst ) )
if Path(dst).exists():
shutil.rmtree(
dst
)
shutil.copytree(
src=src,
dst=dst
)
def create_dirs( config ):
create_dir(
BASE_DIR / config['INPUT_DIR']
)
create_dir(
BASE_DIR / config['OUTPUT_DIR']
)
def install_git_dep(
repo_name,
repo_uri,
repo_hash,
init_script = None
):
if (DEP_DIR / repo_name).exists():
shutil.rmtree( DEP_DIR / repo_name )
subprocess.check_call(
["git", "clone", repo_uri, DEP_DIR / repo_name]
)
subprocess.check_call(
["git", "checkout", repo_hash],
cwd = DEP_DIR / repo_name
)
if init_script is not None:
subprocess.check_call(
shlex.split( init_script ),
cwd = DEP_DIR / repo_name
)
if __name__ == '__main__':
from argparse import ArgumentParser
parser = ArgumentParser(
description="initialize the repository: download git deps, create directories, etc"
)
parser.add_argument(
"--build",
action = "store_true"
)
args = parser.parse_args()
# orig_config_file -> env_file:
create_docker_env_file()
# load env_file:
config = load_config()
## install git dependencies:
'''
install_git_dep(
repo_name = "eoa-publication-model",
repo_uri = "https://github.molgen.mpg.de/EditionOpenAccess/eoa-publication-model.git",
repo_hash = "d76a81feef1ebb708a90376d3f5a7eccb51807b0"
)
'''
create_dirs( config )
# rebuild docker image:
if args.build:
run(
env = config,
build = True,
)