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.update_status_bar, "update-status-bar")
|
||||
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.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)
|
||||
@ -115,10 +116,14 @@ class Controller(object):
|
||||
pub.unsubscribe(self.in_post, "posted")
|
||||
pub.unsubscribe(self.download, "download-file")
|
||||
pub.unsubscribe(self.play_audio, "play-audio")
|
||||
pub.unsubscribe(self.authorisation_failed, "authorisation-failed")
|
||||
pub.unsubscribe(self.play_audios, "play-audios")
|
||||
pub.unsubscribe(self.view_post, "open-post")
|
||||
pub.unsubscribe(self.update_status_bar, "update-status-bar")
|
||||
|
||||
def authorisation_failed(self):
|
||||
commonMessages.bad_authorisation()
|
||||
|
||||
def login(self):
|
||||
self.window.change_status(_(u"Logging in VK"))
|
||||
self.session.login()
|
||||
|
@ -8,6 +8,8 @@ import logging
|
||||
import utils
|
||||
import sound
|
||||
from config_utils import Configuration, ConfigurationResetException
|
||||
from pubsub import pub
|
||||
|
||||
log = logging.getLogger("session")
|
||||
|
||||
sessions = {}
|
||||
@ -222,9 +224,15 @@ class vkSession(object):
|
||||
self.get_my_data()
|
||||
|
||||
def authorise(self):
|
||||
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"])
|
||||
self.settings["vk"]["token"] = self.vk.client._session.access_token
|
||||
self.settings.write()
|
||||
try:
|
||||
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"])
|
||||
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):
|
||||
""" 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))
|
||||
config_test = Configuration(strconfig)
|
||||
name = config_test["vk"]["user"]
|
||||
self.session = i
|
||||
s = session.vkSession(self.session)
|
||||
s.get_configuration()
|
||||
session.sessions[self.session] = s
|
||||
if name != "" and config_test["vk"]["password"] != "":
|
||||
self.session = i
|
||||
s = session.vkSession(self.session)
|
||||
s.get_configuration()
|
||||
session.sessions[self.session] = s
|
||||
|
||||
def manage_new_account(self):
|
||||
if view.new_account_dialog() == widgetUtils.YES:
|
||||
|
@ -20,4 +20,7 @@ def show_error_code(code):
|
||||
if code == 201:
|
||||
title = _(u"Restricted access")
|
||||
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.Layout()
|
||||
self.SetSize(self.GetBestSize())
|
||||
print self.GetSize()
|
||||
|
||||
def change_status(self, status):
|
||||
self.sb.SetStatusText(status)
|
||||
|
Loading…
Reference in New Issue
Block a user