Spaces:
Running
Running
Download update.py from CuteStarOC01/MX01: direct link, hf CLI and curl.
- Browser
- Download file 1.22 kB
-
https://huggingface.co/spaces/CuteStarOC01/MX01/resolve/main/update.py
- Command line
-
hf download hf://spaces/CuteStarOC01/MX01/update.py
-
curl -L -o update.py https://huggingface.co/spaces/CuteStarOC01/MX01/resolve/main/update.py
1.22 kB
| from os import path as ospath | |
| from subprocess import run as srun | |
| from os import environ | |
| UPSTREAM_REPO = environ.get("UPSTREAM_REPO", "") # SSH URL for private repo | |
| UPSTREAM_BRANCH = environ.get("UPSTREAM_BRANCH", "master") | |
| GITHUB_EMAIL = environ.get("GITHUB_EMAIL", "random@gmail.com") | |
| GITHUB_USERNAME = environ.get("GITHUB_USERNAME", "random") | |
| if UPSTREAM_REPO: | |
| if ospath.exists(".git"): | |
| srun(["rm", "-rf", ".git"]) | |
| try: | |
| update = srun( | |
| [ | |
| f"git init -q \ | |
| && git config --global user.email {GITHUB_EMAIL} \ | |
| && git config --global user.name {GITHUB_USERNAME} \ | |
| && git add . \ | |
| && git commit -sm update -q \ | |
| && git remote add origin {UPSTREAM_REPO} \ | |
| && git fetch origin -q \ | |
| && git reset --hard origin/{UPSTREAM_BRANCH} -q" | |
| ], | |
| shell=True, | |
| ) | |
| if update.returncode == 0: | |
| print("Successfully updated with latest commit from UPSTREAM_REPO") | |
| else: | |
| print("Something went wrong while updating, check UPSTREAM_REPO if valid or not!") | |
| except Exception as err: | |
| print(err) | |