-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added update check on startup, updated requirements
- Loading branch information
Showing
5 changed files
with
195 additions
and
363 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,31 @@ | ||
from dev_tray import tray | ||
from dev_autopilot import resource_path, RELEASE | ||
import requests | ||
import tkinter as tk | ||
from tkinter import messagebox | ||
import webbrowser | ||
|
||
def update(): | ||
releases_url = 'https://api.github.com/repos/skai2/EDAutopilot/releases' | ||
response = requests.get(releases_url) | ||
# Raise an exception if the API call fails. | ||
response.raise_for_status() | ||
data = response.json() | ||
try: | ||
latest_release = data[0]['tag_name'] | ||
except Exception as e: | ||
print(e) | ||
if latest_release and latest_release != RELEASE: | ||
message = "There is a new version of EDAutopilot available!\nWould you like to go to the release download page?" | ||
root = tk.Tk() | ||
root.withdraw() | ||
root.tk.call('wm', 'iconphoto', root._w, tk.PhotoImage(file=resource_path('src/logo.png'))) | ||
go_to_update = messagebox.askyesno("ED - Autopilot Update", message) | ||
if go_to_update: | ||
webbrowser.open_new(data[0]['html_url']) | ||
return True | ||
return False | ||
|
||
if __name__ == '__main__': | ||
tray() | ||
if not update(): | ||
tray() |
Oops, something went wrong.