import subprocess as sp import json import os def install_available(project_path): if get_distro_name() == "alpine": sp.check_output(['pipenv', 'lock']) with open(os.path.join(project_path, "Pipfile.lock")) as f: content = json.load(f) for package in content["default"].keys(): try: sp.check_output(["apk", "add", f"py3-{package}"], stderr=sp.DEVNULL) except Exception: pass def clone_common(path='.'): sp.check_output(['git', 'clone', f'https://code.ungleich.ch/ungleich-public/ucloud_common'], cwd=path) def clone_etcd_wrapper(path='.'): sp.check_output(['git', 'clone', f'https://code.ungleich.ch/ahmedbilal/etcd3_wrapper'], cwd=path) def get_distro_name(): distro_name = None with open("/etc/os-release") as f: content = f.read() start = content.find("ID=") + 3 end = content.find("\n", start) distro_name = content[start:end] return distro_name