Show error when fail to connect

This commit is contained in:
Alexis Delhaie
2020-12-19 22:45:00 +01:00
parent 65eec114ae
commit 26ab14c154

32
main.py
View File

@@ -6,6 +6,7 @@ import sys
from threading import Thread from threading import Thread
import requests import requests
from requests.exceptions import ConnectionError
import wx import wx
from wx import Size, Point from wx import Size, Point
@@ -64,16 +65,22 @@ class MyApplication(wx.App):
def OnInit(self): def OnInit(self):
self.SetAppName(WINDOW_TITLE) self.SetAppName(WINDOW_TITLE)
if is_admin(): if is_admin():
version = get_version_from_repo() try:
create_install_folder() version = get_version_from_repo()
if get_installed_version() != version: create_install_folder()
dlg = MyDialog(None, -1, WINDOW_TITLE, version, Size(400, 120)) if get_installed_version() != version:
dlg.ShowModal() dlg = MyDialog(None, -1, WINDOW_TITLE, version, Size(400, 120))
dlg.Destroy() dlg.ShowModal()
if os.path.exists(EXECUTABLE_PATH): dlg.Destroy()
subprocess.Popen([EXECUTABLE_PATH], cwd=INSTALL_FOLDER) if os.path.exists(EXECUTABLE_PATH):
else: subprocess.Popen([EXECUTABLE_PATH], cwd=INSTALL_FOLDER)
dlg = wx.MessageDialog(None, "Installer executable not found", else:
dlg = wx.MessageDialog(None, "Installer executable not found",
WINDOW_TITLE, style=wx.OK | wx.ICON_HAND)
dlg.ShowModal()
dlg.Destroy()
except Exception as e:
dlg = wx.MessageDialog(None, str(e),
WINDOW_TITLE, style=wx.OK | wx.ICON_HAND) WINDOW_TITLE, style=wx.OK | wx.ICON_HAND)
dlg.ShowModal() dlg.ShowModal()
dlg.Destroy() dlg.Destroy()
@@ -187,6 +194,11 @@ class WorkerThread(Thread):
file = open(INSTALLED_VERSION_PATH, "w") file = open(INSTALLED_VERSION_PATH, "w")
file.write(self.version) file.write(self.version)
file.close() file.close()
except Exception as e:
dlg = wx.MessageDialog(None, str(e),
WINDOW_TITLE, style=wx.OK | wx.ICON_HAND)
dlg.ShowModal()
dlg.Destroy()
finally: finally:
wx.PostEvent(self.dlg, ProcessTerminated()) wx.PostEvent(self.dlg, ProcessTerminated())