forked from skai2/EDAutopilot
-
Notifications
You must be signed in to change notification settings - Fork 2
/
autopilot.py
35 lines (29 loc) · 1.09 KB
/
autopilot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import tkinter as tk
import webbrowser
from tkinter import messagebox
import requests
from dev_autopilot import resource_path, RELEASE
from dev_tray import tray
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']
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
except Exception as e:
print(e)
return False
if __name__ == '__main__':
if not update():
tray()