-
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
FLOCK4H
committed
May 27, 2024
1 parent
84040d9
commit 8673b8e
Showing
9 changed files
with
60 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import requests | ||
import subprocess | ||
from FreewayTools.colors import * | ||
import time | ||
|
||
GITHUB_REPO = "FLOCK4H/Freeway" | ||
|
||
def get_latest_version(): | ||
try: | ||
# This is an API created & hosted by github, not by me, | ||
# it's the safest way of checking the most recent version of Freeway | ||
|
||
url = f"https://api.github.com/repos/{GITHUB_REPO}/releases/latest" | ||
response = requests.get(url) | ||
response.raise_for_status() | ||
latest_release = response.json() | ||
return latest_release["tag_name"] | ||
except ConnectionError: | ||
pass | ||
except Exception as e: | ||
wprint(str(e)) | ||
|
||
def get_current_version(): | ||
return "1.2.0" | ||
|
||
def update(): | ||
cprint("Checking for updates..") | ||
|
||
current_version = get_current_version() | ||
latest_version = get_latest_version() | ||
if latest_version is None: | ||
wprint("You are not connected to any network, I can't fetch updates...") | ||
time.sleep(0.8) | ||
return | ||
|
||
if current_version != latest_version: | ||
cprint(f"New version available: {latest_version}") | ||
if cinput("Update Freeway? (y/n)") == "y": | ||
subprocess.run(["git", "pull", "origin", "main"], check=True) | ||
iprint("Update completed. Please restart Freeway.") | ||
else: | ||
iprint("You are using the latest version of Freeway.") | ||
time.sleep(0.8) | ||
|
||
if __name__ == "__main__": | ||
update() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters