This repository has been archived on 2021-07-03. You can view files and clone it, but cannot push or open issues or pull requests.
abra/app-json.py
2021-03-26 20:21:37 +01:00

37 lines
941 B
Python
Executable File

#!/usr/bin/env python3
from os import chdir, mkdir
from os.path import exists, expanduser
from pathlib import Path
from shlex import split
from subprocess import check_output, run
from requests import get
def clone_apps():
home = expanduser("~/")
clones = Path(f"{home}/.abra/apps").absolute()
if not exists(clones):
mkdir(clones)
response = get("https://git.autonomic.zone/api/v1/orgs/coop-cloud/repos")
repos = [[p["name"], p["ssh_url"]] for p in response.json()]
for name, url in repos:
try:
if not exists(f"{clones}/{name}"):
run(split(f"git clone {url} {clones}/{name}"))
chdir(f"{clones}/{name}")
if not int(check_output("git branch --list | wc -l", shell=True)):
run(split("git checkout main"))
except Exception:
pass
def main():
clone_apps()
if __name__ == "__main__":
main()