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

12
main.py
View File

@@ -6,6 +6,7 @@ import sys
from threading import Thread
import requests
from requests.exceptions import ConnectionError
import wx
from wx import Size, Point
@@ -64,6 +65,7 @@ class MyApplication(wx.App):
def OnInit(self):
self.SetAppName(WINDOW_TITLE)
if is_admin():
try:
version = get_version_from_repo()
create_install_folder()
if get_installed_version() != version:
@@ -77,6 +79,11 @@ class MyApplication(wx.App):
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)
dlg.ShowModal()
dlg.Destroy()
else:
dlg = wx.MessageDialog(None, "This application requires administrative privileges to run",
WINDOW_TITLE, style=wx.OK | wx.ICON_HAND)
@@ -187,6 +194,11 @@ class WorkerThread(Thread):
file = open(INSTALLED_VERSION_PATH, "w")
file.write(self.version)
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:
wx.PostEvent(self.dlg, ProcessTerminated())