mirror of
https://github.com/norohind/EDMC_SpanshRouter.git
synced 2026-10-22 18:02:08 +03:00
Download and install the update according to what the user chose
This commit is contained in:
1 parent
7875825f57
commit
cee1a15193
2 files changed
+11
-12
No files matched your search
@@ -111,11 +111,13 @@ class SpanshRouter():
|
||||
update_txt = "New Spansh update available!\n"
|
||||
update_txt += "If you choose to install it, you will have to restart EDMC for it to take effect.\n\n"
|
||||
update_txt += self.spansh_updater.changelogs
|
||||
update_txt += "Install?"
|
||||
update_txt += "\n\nInstall?"
|
||||
install_update = confirmDialog.askyesno("SpanshRouter", update_txt)
|
||||
|
||||
if install_update:
|
||||
confirmDialog.showinfo("SpanshRouter", "The update will be installed as soon as you close EDMC.")
|
||||
confirmDialog.showinfo("SpanshRouter", "The update will be installed as soon as you quit EDMC.")
|
||||
else:
|
||||
self.update_available = False
|
||||
|
||||
self.update_gui()
|
||||
|
||||
@@ -570,11 +572,6 @@ class SpanshRouter():
|
||||
self.update_available = True
|
||||
self.spansh_updater = SpanshUpdater(response.content, self.plugin_dir)
|
||||
|
||||
if self.spansh_updater.download_zip():
|
||||
self.spansh_updater.get_changelog()
|
||||
else:
|
||||
sys.stderr.write("Error when downloading the latest SpanshRouter update")
|
||||
|
||||
else:
|
||||
sys.stderr.write("Could not query latest SpanshRouter version: " + str(response.status_code) + response.text)
|
||||
except:
|
||||
|
||||
@@ -14,7 +14,7 @@ class SpanshUpdater():
|
||||
self.plugin_dir = plugin_dir
|
||||
self.zip_path = os.path.join(self.plugin_dir, self.zip_name)
|
||||
self.zip_downloaded = False
|
||||
self.changelogs = ""
|
||||
self.changelogs = self.get_changelog()
|
||||
|
||||
def download_zip(self):
|
||||
url = 'https://github.com/CMDR-Kiel42/EDMC_SpanshRouter/releases/download/v' + self.version + '/' + self.zip_name
|
||||
@@ -38,7 +38,7 @@ class SpanshUpdater():
|
||||
return self.zip_downloaded
|
||||
|
||||
def install(self):
|
||||
if self.zip_downloaded:
|
||||
if self.download_zip():
|
||||
try:
|
||||
with zipfile.ZipFile(self.zip_path, 'r') as zip_ref:
|
||||
zip_ref.extractall(self.plugin_dir)
|
||||
@@ -48,6 +48,8 @@ class SpanshUpdater():
|
||||
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))
|
||||
else:
|
||||
sys.stderr.write("Error when downloading the latest SpanshRouter update")
|
||||
|
||||
def get_changelog(self):
|
||||
url = "https://api.github.com/repos/CMDR-Kiel42/EDMC_SpanshRouter/releases/latest"
|
||||
@@ -56,9 +58,9 @@ class SpanshUpdater():
|
||||
|
||||
if r.status_code == 200:
|
||||
# Get the changelog and replace all breaklines with simple ones
|
||||
self.changelogs = json.loads(r.content)["body"]
|
||||
self.changelogs = "\n".join(self.changelogs.splitlines())
|
||||
pass
|
||||
changelogs = json.loads(r.content)["body"]
|
||||
changelogs = "\n".join(changelogs.splitlines())
|
||||
return changelogs
|
||||
|
||||
except:
|
||||
exc_type, exc_value, exc_traceback = sys.exc_info()
|
||||
|
||||
Reference in new issue
Block a user