display error if there is an internet connection problem during startup

This commit is contained in:
2019-02-14 08:36:31 -06:00
parent 942f9296a0
commit 4c220cbb36
3 changed files with 17 additions and 1 deletions

View File

@@ -286,6 +286,7 @@ class Controller(object):
pub.subscribe(self.update_status_bar, "update-status-bar")
pub.subscribe(self.chat_from_id, "new-chat")
pub.subscribe(self.authorisation_failed, "authorisation-failed")
pub.subscribe(self.connection_error, "connection_error")
pub.subscribe(self.user_profile, "user-profile")
pub.subscribe(self.user_online, "user-online")
pub.subscribe(self.user_offline, "user-offline")
@@ -391,6 +392,15 @@ class Controller(object):
commonMessages.bad_authorisation()
restart.restart_program()
def connection_error(self, *args, **kwargs):
commonMessages.connection_error()
self.disconnect_events()
volume = player.player.volume
config.app["sound"]["volume"] = volume
config.app.write()
self.window.Destroy()
wx.GetApp().ExitMainLoop()
def user_profile(self, person):
""" display someone's profile. For now, only users are supported."""
p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor())

View File

@@ -8,6 +8,7 @@ import languageHandler
import paths
import config
import sound
from requests.exceptions import ProxyError, ConnectionError
from .config_utils import Configuration, ConfigurationResetException
from . import vkSessionHandler
from pubsub import pub
@@ -110,6 +111,8 @@ class vkSession(object):
# log.exception("The session configuration has failed.")
def login(self):
""" Logging in VK.com. This is basically the first method interacting with VK. """
# If user is already logged in, we should skip this method.
if self.logged == True:
return
try:
@@ -130,10 +133,12 @@ class vkSession(object):
self.settings["vk"]["device_id"] = ""
self.settings.write()
pub.sendMessage("authorisation-failed")
else: # print out error so we we will handle it.
else: # print out error so we we will handle it in future versions.
log.exception("Fatal error when authenticating the application.")
log.exception(error.code)
log.exception(error.message)
except (ProxyError, ConnectionError):
pub.sendMessage("connection_error")
def post_wall_status(self, message, *args, **kwargs):
""" Sends a post to an user, group or community wall."""