Added an error message when there is an exception in authorisation
This commit is contained in:
parent
4df4e620c1
commit
2b9aa467bd
@ -98,6 +98,7 @@ class Controller(object):
|
|||||||
pub.subscribe(self.view_post, "open-post")
|
pub.subscribe(self.view_post, "open-post")
|
||||||
pub.subscribe(self.update_status_bar, "update-status-bar")
|
pub.subscribe(self.update_status_bar, "update-status-bar")
|
||||||
pub.subscribe(self.chat_from_id, "new-chat")
|
pub.subscribe(self.chat_from_id, "new-chat")
|
||||||
|
pub.subscribe(self.authorisation_failed, "authorisation-failed")
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
|
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
|
||||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
|
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
|
||||||
@ -115,10 +116,14 @@ class Controller(object):
|
|||||||
pub.unsubscribe(self.in_post, "posted")
|
pub.unsubscribe(self.in_post, "posted")
|
||||||
pub.unsubscribe(self.download, "download-file")
|
pub.unsubscribe(self.download, "download-file")
|
||||||
pub.unsubscribe(self.play_audio, "play-audio")
|
pub.unsubscribe(self.play_audio, "play-audio")
|
||||||
|
pub.unsubscribe(self.authorisation_failed, "authorisation-failed")
|
||||||
pub.unsubscribe(self.play_audios, "play-audios")
|
pub.unsubscribe(self.play_audios, "play-audios")
|
||||||
pub.unsubscribe(self.view_post, "open-post")
|
pub.unsubscribe(self.view_post, "open-post")
|
||||||
pub.unsubscribe(self.update_status_bar, "update-status-bar")
|
pub.unsubscribe(self.update_status_bar, "update-status-bar")
|
||||||
|
|
||||||
|
def authorisation_failed(self):
|
||||||
|
commonMessages.bad_authorisation()
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
self.window.change_status(_(u"Logging in VK"))
|
self.window.change_status(_(u"Logging in VK"))
|
||||||
self.session.login()
|
self.session.login()
|
||||||
|
@ -8,6 +8,8 @@ import logging
|
|||||||
import utils
|
import utils
|
||||||
import sound
|
import sound
|
||||||
from config_utils import Configuration, ConfigurationResetException
|
from config_utils import Configuration, ConfigurationResetException
|
||||||
|
from pubsub import pub
|
||||||
|
|
||||||
log = logging.getLogger("session")
|
log = logging.getLogger("session")
|
||||||
|
|
||||||
sessions = {}
|
sessions = {}
|
||||||
@ -222,9 +224,15 @@ class vkSession(object):
|
|||||||
self.get_my_data()
|
self.get_my_data()
|
||||||
|
|
||||||
def authorise(self):
|
def authorise(self):
|
||||||
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"])
|
try:
|
||||||
self.settings["vk"]["token"] = self.vk.client._session.access_token
|
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"])
|
||||||
self.settings.write()
|
self.settings["vk"]["token"] = self.vk.client._session.access_token
|
||||||
|
self.settings.write()
|
||||||
|
except:
|
||||||
|
self.settings["vk"]["user"] = ""
|
||||||
|
self.settings["vk"]["password"] = ""
|
||||||
|
self.settings.write()
|
||||||
|
pub.sendMessage("authorisation-failed")
|
||||||
|
|
||||||
def post_wall_status(self, message, *args, **kwargs):
|
def post_wall_status(self, message, *args, **kwargs):
|
||||||
""" Sends a post to an user, group or community wall."""
|
""" Sends a post to an user, group or community wall."""
|
||||||
|
@ -28,10 +28,11 @@ class sessionManagerController(object):
|
|||||||
strconfig = "%s/session.conf" % (paths.config_path(i))
|
strconfig = "%s/session.conf" % (paths.config_path(i))
|
||||||
config_test = Configuration(strconfig)
|
config_test = Configuration(strconfig)
|
||||||
name = config_test["vk"]["user"]
|
name = config_test["vk"]["user"]
|
||||||
self.session = i
|
if name != "" and config_test["vk"]["password"] != "":
|
||||||
s = session.vkSession(self.session)
|
self.session = i
|
||||||
s.get_configuration()
|
s = session.vkSession(self.session)
|
||||||
session.sessions[self.session] = s
|
s.get_configuration()
|
||||||
|
session.sessions[self.session] = s
|
||||||
|
|
||||||
def manage_new_account(self):
|
def manage_new_account(self):
|
||||||
if view.new_account_dialog() == widgetUtils.YES:
|
if view.new_account_dialog() == widgetUtils.YES:
|
||||||
|
@ -20,4 +20,7 @@ def show_error_code(code):
|
|||||||
if code == 201:
|
if code == 201:
|
||||||
title = _(u"Restricted access")
|
title = _(u"Restricted access")
|
||||||
message = _(u"Access to user's audio is denied by the owner. Error code {0}").format(code,)
|
message = _(u"Access to user's audio is denied by the owner. Error code {0}").format(code,)
|
||||||
return wx.MessageDialog(None, message, title, style=wx.ICON_ERROR).ShowModal()
|
return wx.MessageDialog(None, message, title, style=wx.ICON_ERROR).ShowModal()
|
||||||
|
|
||||||
|
def bad_authorisation():
|
||||||
|
return wx.MessageDialog(None, _(u"authorisation failed. Your configuration will not be saved. Please close and open again the application for authorising your account. Make sure you have typed your credentials correctly."), _(u"Error"), style=wx.ICON_ERROR).ShowModal()
|
@ -38,7 +38,6 @@ class mainWindow(wx.Frame):
|
|||||||
self.SetClientSize(self.sizer.CalcMin())
|
self.SetClientSize(self.sizer.CalcMin())
|
||||||
self.Layout()
|
self.Layout()
|
||||||
self.SetSize(self.GetBestSize())
|
self.SetSize(self.GetBestSize())
|
||||||
print self.GetSize()
|
|
||||||
|
|
||||||
def change_status(self, status):
|
def change_status(self, status):
|
||||||
self.sb.SetStatusText(status)
|
self.sb.SetStatusText(status)
|
||||||
|
Loading…
Reference in New Issue
Block a user