Fixed error when getting VK API error 5. Closes #11

This commit is contained in:
Manuel Cortez 2018-09-03 09:15:52 -05:00
parent 72348008a2
commit e77276ae52

View File

@ -9,6 +9,7 @@ import utils
import sound
from config_utils import Configuration, ConfigurationResetException
from pubsub import pub
from vk.exceptions import VkAPIError
log = logging.getLogger("session")
@ -218,11 +219,15 @@ class vkSession(object):
If the access_token has expired, it will call authorise() too, for getting a new access token."""
if self.settings["vk"]["token"] != None:
try:
result = self.vk.login_access_token(self.settings["vk"]["token"])
self.logged = True
log.debug("Logged.")
if result == False:
self.authorise()
except VkAPIError as err:
if err.code == 5:
self.authorise()
else:
self.authorise()
self.get_my_data()