Flesh out more of this generation script
This commit is contained in:
parent
a5274f123c
commit
6f3f4b6779
57
app-json.py
57
app-json.py
@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from os import chdir, mkdir
|
from os import chdir, listdir, mkdir
|
||||||
from os.path import exists, expanduser
|
from os.path import exists, expanduser
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shlex import split
|
from shlex import split
|
||||||
@ -8,28 +8,69 @@ from subprocess import check_output, run
|
|||||||
|
|
||||||
from requests import get
|
from requests import get
|
||||||
|
|
||||||
|
HOME_PATH = expanduser("~/")
|
||||||
|
CLONES_PATH = Path(f"{HOME_PATH}/.abra/apps").absolute()
|
||||||
|
|
||||||
|
|
||||||
def clone_apps():
|
def clone_apps():
|
||||||
home = expanduser("~/")
|
if not exists(CLONES_PATH):
|
||||||
clones = Path(f"{home}/.abra/apps").absolute()
|
mkdir(CLONES_PATH)
|
||||||
if not exists(clones):
|
|
||||||
mkdir(clones)
|
|
||||||
|
|
||||||
response = get("https://git.autonomic.zone/api/v1/orgs/coop-cloud/repos")
|
response = get("https://git.autonomic.zone/api/v1/orgs/coop-cloud/repos")
|
||||||
repos = [[p["name"], p["ssh_url"]] for p in response.json()]
|
repos = [[p["name"], p["ssh_url"]] for p in response.json()]
|
||||||
|
|
||||||
|
skips = ("organising", "cloud.autonomic.zone", "docs.cloud.autonomic.zone", "abra")
|
||||||
|
|
||||||
for name, url in repos:
|
for name, url in repos:
|
||||||
|
if name in skips:
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not exists(f"{clones}/{name}"):
|
if not exists(f"{CLONES_PATH}/{name}"):
|
||||||
run(split(f"git clone {url} {clones}/{name}"))
|
run(split(f"git clone {url} {CLONES_PATH}/{name}"))
|
||||||
chdir(f"{clones}/{name}")
|
chdir(f"{CLONES_PATH}/{name}")
|
||||||
if not int(check_output("git branch --list | wc -l", shell=True)):
|
if not int(check_output("git branch --list | wc -l", shell=True)):
|
||||||
run(split("git checkout main"))
|
run(split("git checkout main"))
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def gen_apps_json():
|
||||||
|
apps_json = {}
|
||||||
|
|
||||||
|
for app in listdir(CLONES_PATH):
|
||||||
|
app_path = f"{CLONES_PATH}/{app}"
|
||||||
|
chdir(app_path)
|
||||||
|
|
||||||
|
output = check_output("git tag --list", shell=True)
|
||||||
|
tags = output.strip().decode("utf-8")
|
||||||
|
|
||||||
|
if not tags:
|
||||||
|
print(f"Skipping {app} because there are no tags")
|
||||||
|
continue
|
||||||
|
|
||||||
|
for tag in tags:
|
||||||
|
apps_json[app] = {
|
||||||
|
"category": "apps",
|
||||||
|
"repository": f"https://git.autonomic.zone/coop-cloud/{app}.git",
|
||||||
|
"features": get_app_features(),
|
||||||
|
"versions": get_app_versions(),
|
||||||
|
}
|
||||||
|
|
||||||
|
return apps_json
|
||||||
|
|
||||||
|
|
||||||
|
def get_app_features():
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
def get_app_versions():
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
clone_apps()
|
clone_apps()
|
||||||
|
print(gen_apps_json())
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user