mirror of
https://github.com/norohind/EDMC_SpanshRouter.git
synced 2025-06-20 08:43:51 +03:00
Fetch the changelogs and display them in a popup asking if we should install
This commit is contained in:
parent
26efd0b680
commit
24e15111b8
@ -108,14 +108,15 @@ class SpanshRouter():
|
|||||||
self.clear_route_btn.grid_remove()
|
self.clear_route_btn.grid_remove()
|
||||||
|
|
||||||
if self.update_available:
|
if self.update_available:
|
||||||
update_txt = ("A SpanshRouter update is available.\n"
|
update_txt = "New Spansh update available!\n"
|
||||||
"It will be installed next time you start EDMC.\n"
|
update_txt += "If you choose to install it, you will have to restart EDMC for it to take effect.\n\n"
|
||||||
"Click to dismiss this message, right click to see what's new.")
|
update_txt += self.spansh_updater.changelogs
|
||||||
self.update_btn = tk.Button(self.frame, text=update_txt, command=lambda: self.update_btn.grid_forget())
|
update_txt += "Install?"
|
||||||
self.update_btn.bind("<Button-3>", self.goto_changelog_page)
|
install_update = confirmDialog.askyesno("SpanshRouter", update_txt)
|
||||||
self.update_btn.grid(row=row, pady=5, columnspan=2)
|
|
||||||
row += 1
|
|
||||||
|
|
||||||
|
if install_update:
|
||||||
|
confirmDialog.showinfo("SpanshRouter", "The update will be installed as soon as you close EDMC.")
|
||||||
|
|
||||||
self.update_gui()
|
self.update_gui()
|
||||||
|
|
||||||
return self.frame
|
return self.frame
|
||||||
@ -560,17 +561,20 @@ class SpanshRouter():
|
|||||||
|
|
||||||
def check_for_update(self):
|
def check_for_update(self):
|
||||||
self.cleanup_old_version()
|
self.cleanup_old_version()
|
||||||
url = "https://raw.githubusercontent.com/CMDR-Kiel42/EDMC_SpanshRouter/master/version.json"
|
version_url = "https://raw.githubusercontent.com/CMDR-Kiel42/EDMC_SpanshRouter/master/version.json"
|
||||||
try:
|
try:
|
||||||
response = requests.get(url, timeout=2)
|
response = requests.get(version_url, timeout=2)
|
||||||
|
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
if self.plugin_version != response.content:
|
if self.plugin_version != response.content:
|
||||||
self.update_available = True
|
self.update_available = True
|
||||||
self.spansh_updater = SpanshUpdater(response.content, self.plugin_dir)
|
self.spansh_updater = SpanshUpdater(response.content, self.plugin_dir)
|
||||||
|
|
||||||
if not self.spansh_updater.download_zip():
|
if self.spansh_updater.download_zip():
|
||||||
|
self.spansh_updater.get_changelog()
|
||||||
|
else:
|
||||||
sys.stderr.write("Error when downloading the latest SpanshRouter update")
|
sys.stderr.write("Error when downloading the latest SpanshRouter update")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
sys.stderr.write("Could not query latest SpanshRouter version: " + str(response.status_code) + response.text)
|
sys.stderr.write("Could not query latest SpanshRouter version: " + str(response.status_code) + response.text)
|
||||||
except:
|
except:
|
||||||
|
@ -13,6 +13,7 @@ class SpanshUpdater():
|
|||||||
self.plugin_dir = plugin_dir
|
self.plugin_dir = plugin_dir
|
||||||
self.zip_path = os.path.join(self.plugin_dir, self.zip_name)
|
self.zip_path = os.path.join(self.plugin_dir, self.zip_name)
|
||||||
self.zip_downloaded = False
|
self.zip_downloaded = False
|
||||||
|
self.changelogs = ""
|
||||||
|
|
||||||
def download_zip(self):
|
def download_zip(self):
|
||||||
url = 'https://github.com/CMDR-Kiel42/EDMC_SpanshRouter/releases/download/v' + self.version + '/' + self.zip_name
|
url = 'https://github.com/CMDR-Kiel42/EDMC_SpanshRouter/releases/download/v' + self.version + '/' + self.zip_name
|
||||||
@ -46,3 +47,17 @@ class SpanshUpdater():
|
|||||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
||||||
sys.stderr.write(''.join('!! ' + line for line in lines))
|
sys.stderr.write(''.join('!! ' + line for line in lines))
|
||||||
|
|
||||||
|
def get_changelog(self):
|
||||||
|
url = "https://raw.githubusercontent.com/CMDR-Kiel42/EDMC_SpanshRouter/master/CHANGELOG.md"
|
||||||
|
try:
|
||||||
|
r = requests.get(url, timeout=2)
|
||||||
|
|
||||||
|
if r.status_code == 200:
|
||||||
|
start_index = r.content.find("## " + self.version)
|
||||||
|
stop_index = r.content.find("##", start_index + 2)
|
||||||
|
self.changelogs = r.content[start_index: stop_index:]
|
||||||
|
except:
|
||||||
|
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||||
|
lines = traceback.format_exception(exc_type, exc_value, exc_traceback)
|
||||||
|
sys.stderr.write(''.join('!! ' + line for line in lines))
|
Loading…
x
Reference in New Issue
Block a user