def is_docker_available(): devnull = open(os.devnull, 'w') try: py_call(["docker", "--help"], stdout=devnull, stderr=devnull) return True except Exception: return False
def docker_run(): create_pom_from_config() py_call(["docker", "run", "--mount", "src=" + _MY_DIR + ",target=/app,type=bind", "pydl4j"]) # docker will build into <context>/target, need to move to context dir context_dir = get_dir() config = get_config() dl4j_version = config['dl4j_version'] jar_name = "pydl4j-{}-bin.jar".format(dl4j_version) base_target_dir = os.path.join(_MY_DIR, "target") source = os.path.join(base_target_dir, jar_name) target = os.path.join(context_dir, jar_name) _write_config(os.path.join(context_dir, 'config.json')) os.rename(source, target)
def call(arglist): error = py_call(arglist) if error: raise Exception('Subprocess error for command: ' + str(arglist))