import subprocess import sys BUILDDIR = "services" BREWERY_URL = "https://github.com/iritmaximus/brewery.git" PUMPPI_URL = "https://github.com/iritmaximus/pumppistatus.git" TIMETRIALS_URL = "https://github.com/iritmaximus/timetrials.git" REAKTOR_BACKEND_URL = "https://github.com/iritmaximus/reaktor-backend.git" BORT_URL="https://github.com/iritmaximus/bort.git" projects = [ BREWERY_URL, PUMPPI_URL, TIMETRIALS_URL, REAKTOR_BACKEND_URL, BORT_URL ] def main(): if len(sys.argv) < 2: print("No args given. Options are \"init\" and \"sync\"") return for project_url in projects: if sys.argv[1] == "init": pull_project_from_github(project_url) if sys.argv[1] == "sync": update_project(project_url) else: print("no.") def pull_project_from_github(project_url: str): curr_dir = f"{BUILDDIR}/{str(parse_name_from_url(project_url))}" subprocess.run(["git", "clone", str(project_url), curr_dir]) subprocess.run(["touch", f"{curr_dir}/.env"]) def update_project(project_url: str): subprocess.run(["git","-C", "services/" + str(parse_name_from_url(project_url)), "pull"]) def parse_name_from_url(url: str): return url.split("/")[-1].split(".")[0] if __name__ == "__main__": main()