summaryrefslogtreecommitdiffstats
path: root/module/plugins/Account.py
diff options
context:
space:
mode:
Diffstat (limited to 'module/plugins/Account.py')
-rw-r--r--module/plugins/Account.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/module/plugins/Account.py b/module/plugins/Account.py
index e75fc0ecb..f6c59ae25 100644
--- a/module/plugins/Account.py
+++ b/module/plugins/Account.py
@@ -36,16 +36,16 @@ class Account(Base):
associated hoster plugin. Plugin should also provide `loadAccountInfo`
"""
__name__ = "Account"
- __version__ = "0.2"
+ __version__ = "0.3"
__type__ = "account"
__description__ = """Base account plugin"""
__author_name__ = "mkaay"
__author_mail__ = "mkaay@mkaay.de"
- #: after that time [in minutes] pyload will relogin the account
- login_timeout = 600
- #: account data will be reloaded after this time
- info_threshold = 600
+ #: after that time (in minutes) pyload will relogin the account
+ login_timeout = 10 * 60
+ #: after that time (in minutes) account data will be reloaded
+ info_threshold = 10 * 60
def __init__(self, manager, accounts):
@@ -84,17 +84,20 @@ class Account(Base):
self.logWarning(
_("Could not login with account %(user)s | %(msg)s") % {"user": user
, "msg": _("Wrong Password")})
- data["valid"] = False
-
+ success = data["valid"] = False
except Exception, e:
self.logWarning(
_("Could not login with account %(user)s | %(msg)s") % {"user": user
, "msg": e})
- data["valid"] = False
+ success = data["valid"] = False
if self.core.debug:
print_exc()
+ else:
+ success = True
finally:
- if req: req.close()
+ if req:
+ req.close()
+ return success
def relogin(self, user):
req = self.getAccountRequest(user)
@@ -104,7 +107,7 @@ class Account(Base):
if user in self.infos:
del self.infos[user] #delete old information
- self._login(user, self.accounts[user])
+ return self._login(user, self.accounts[user])
def setAccounts(self, accounts):
self.accounts = accounts
@@ -284,9 +287,10 @@ class Account(Base):
def checkLogin(self, user):
""" checks if user is still logged in """
if user in self.timestamps:
- if self.timestamps[user] + self.login_timeout * 60 < time():
+ if self.login_timeout > 0 and self.timestamps[user] + login_timeout * 60 > time():
self.logDebug("Reached login timeout for %s" % user)
- self.relogin(user)
- return False
-
- return True
+ return self.relogin(user)
+ else:
+ return True
+ else:
+ return False