2019-09-07 08:10:28 +00:00
|
|
|
import subprocess as sp
|
2019-09-11 19:16:34 +00:00
|
|
|
import json
|
2019-09-12 08:20:28 +00:00
|
|
|
import os
|
2019-08-28 11:42:50 +00:00
|
|
|
|
2019-09-12 08:20:28 +00:00
|
|
|
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:
|
2019-09-12 08:28:09 +00:00
|
|
|
sp.check_output(["apk", "add", f"py3-{package}"], stderr=sp.DEVNULL)
|
2019-09-12 08:20:28 +00:00
|
|
|
except Exception:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2019-09-07 08:10:28 +00:00
|
|
|
def clone_common(path='.'):
|
|
|
|
sp.check_output(['git', 'clone',
|
2019-09-08 16:00:53 +00:00
|
|
|
f'https://code.ungleich.ch/ungleich-public/ucloud_common'], cwd=path)
|
2019-08-27 08:31:22 +00:00
|
|
|
|
2019-08-28 11:42:50 +00:00
|
|
|
|
2019-09-07 08:10:28 +00:00
|
|
|
def clone_etcd_wrapper(path='.'):
|
|
|
|
sp.check_output(['git', 'clone',
|
2019-09-08 16:00:53 +00:00
|
|
|
f'https://code.ungleich.ch/ahmedbilal/etcd3_wrapper'], cwd=path)
|
2019-08-27 08:31:22 +00:00
|
|
|
|
2019-08-28 11:42:50 +00:00
|
|
|
|
2019-08-28 07:13:05 +00:00
|
|
|
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]
|
2019-09-11 19:16:34 +00:00
|
|
|
return distro_name
|