From a1b105f5e74df07abeab46a29de16416954fe4b8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 2 Jun 2015 03:42:55 +0200 Subject: Small code cosmetics --- module/plugins/accounts/RapideoPl.py | 53 ++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 3e9d52fe8..92736cba0 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -4,77 +4,78 @@ import datetime import hashlib import time +from module.common.json_layer import json_loads from module.plugins.Account import Account -from module.common.json_layer import json_loads as loads class RapideoPl(Account): - __name__ = "RapideoPl" + __name__ = "RapideoPl" + __type__ = "account" __version__ = "0.01" - __type__ = "account" + __description__ = "Rapideo.pl account plugin" - __license__ = "GPLv3" - __authors__ = [("goddie", "dev@rapideo.pl")] + __license__ = "GPLv3" + __authors__ = [("goddie", "dev@rapideo.pl")] - _api_url = "http://enc.rapideo.pl" - _api_query = { - "site": "newrd", - "username": "", - "password": "", - "output": "json", - "loc": "1", - "info": "1" - } + API_URL = "http://enc.rapideo.pl" + API_QUERY = {'site' : "newrd", + 'username': "" , + 'password': "" , + 'output' : "json" , + 'loc' : "1" , + 'info' : "1" } _req = None _usr = None _pwd = None + def loadAccountInfo(self, name, req): self._req = req try: - result = loads(self.runAuthQuery()) + result = json_loads(self.runAuthQuery()) except Exception: # todo: return or let it be thrown? return premium = False valid_untill = -1 + if "expire" in result.keys() and result["expire"]: premium = True valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result["expire"])).timetuple()) traffic_left = result["balance"] - return ({ - "validuntil": valid_untill, - "trafficleft": traffic_left, - "premium": premium - }) + return {'validuntil' : valid_untill, + 'trafficleft': traffic_left, + 'premium' : premium } + def login(self, user, data, req): self._usr = user self._pwd = hashlib.md5(data["password"]).hexdigest() self._req = req + try: - response = loads(self.runAuthQuery()) + response = json_loads(self.runAuthQuery()) except Exception: self.wrongPassword() if "errno" in response.keys(): self.wrongPassword() + data['usr'] = self._usr data['pwd'] = self._pwd + def createAuthQuery(self): - query = self._api_query + query = self.API_QUERY query["username"] = self._usr query["password"] = self._pwd - return query - def runAuthQuery(self): - data = self._req.load(self._api_url, post=self.createAuthQuery()) - return data \ No newline at end of file + def runAuthQuery(self): + return self._req.load(self.API_URL, post=self.createAuthQuery()) -- cgit v1.2.3 From 0e1ef9bc01579328e17e79416fa3c1c7b77adcc8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Mon, 8 Jun 2015 06:08:01 +0200 Subject: Update everything --- module/plugins/accounts/RapideoPl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 92736cba0..5039d1494 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -5,13 +5,13 @@ import hashlib import time from module.common.json_layer import json_loads -from module.plugins.Account import Account +from module.plugins.internal.Account import Account class RapideoPl(Account): __name__ = "RapideoPl" __type__ = "account" - __version__ = "0.01" + __version__ = "0.02" __description__ = "Rapideo.pl account plugin" __license__ = "GPLv3" -- cgit v1.2.3 From c1764e2fea0bb05164c83a876e8cd58b97f58f25 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 16 Jun 2015 17:31:38 +0200 Subject: Update all --- module/plugins/accounts/RapideoPl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 5039d1494..8b868ee07 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -78,4 +78,4 @@ class RapideoPl(Account): def runAuthQuery(self): - return self._req.load(self.API_URL, post=self.createAuthQuery()) + return self._self.load(self.API_URL, post=self.createAuthQuery(), req=req) -- cgit v1.2.3 From 20b6a2ec022202b0efb6cb69415239fb8f4d1445 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 18:59:20 +0200 Subject: Spare code cosmetics (2) --- module/plugins/accounts/RapideoPl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 8b868ee07..0fc934255 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -36,7 +36,7 @@ class RapideoPl(Account): try: result = json_loads(self.runAuthQuery()) except Exception: - # todo: return or let it be thrown? + #@TODO: return or let it be thrown? return premium = False -- cgit v1.2.3 From 9305859b64a2f0aef3f27fb7e5b75caa0cb836a6 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Wed, 17 Jun 2015 19:24:49 +0200 Subject: Spare code cosmetics (3) --- module/plugins/accounts/RapideoPl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 0fc934255..f5ce2e2b1 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -42,11 +42,11 @@ class RapideoPl(Account): premium = False valid_untill = -1 - if "expire" in result.keys() and result["expire"]: + if "expire" in result.keys() and result['expire']: premium = True - valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result["expire"])).timetuple()) + valid_untill = time.mktime(datetime.datetime.fromtimestamp(int(result['expire'])).timetuple()) - traffic_left = result["balance"] + traffic_left = result['balance'] return {'validuntil' : valid_untill, 'trafficleft': traffic_left, @@ -55,7 +55,7 @@ class RapideoPl(Account): def login(self, user, data, req): self._usr = user - self._pwd = hashlib.md5(data["password"]).hexdigest() + self._pwd = hashlib.md5(data['password']).hexdigest() self._req = req try: @@ -72,8 +72,8 @@ class RapideoPl(Account): def createAuthQuery(self): query = self.API_QUERY - query["username"] = self._usr - query["password"] = self._pwd + query['username'] = self._usr + query['password'] = self._pwd return query -- cgit v1.2.3 From b1759bc440cd6013837697eb8de540914f693ffd Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Tue, 7 Jul 2015 01:23:55 +0200 Subject: No camelCase style anymore --- module/plugins/accounts/RapideoPl.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index f5ce2e2b1..1f4140846 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -11,7 +11,7 @@ from module.plugins.internal.Account import Account class RapideoPl(Account): __name__ = "RapideoPl" __type__ = "account" - __version__ = "0.02" + __version__ = "0.03" __description__ = "Rapideo.pl account plugin" __license__ = "GPLv3" @@ -31,10 +31,10 @@ class RapideoPl(Account): _pwd = None - def loadAccountInfo(self, name, req): + def load_account_info(self, name, req): self._req = req try: - result = json_loads(self.runAuthQuery()) + result = json_loads(self.run_auth_query()) except Exception: #@TODO: return or let it be thrown? return @@ -59,23 +59,23 @@ class RapideoPl(Account): self._req = req try: - response = json_loads(self.runAuthQuery()) + response = json_loads(self.run_auth_query()) except Exception: - self.wrongPassword() + self.wrong_password() if "errno" in response.keys(): - self.wrongPassword() + self.wrong_password() data['usr'] = self._usr data['pwd'] = self._pwd - def createAuthQuery(self): + def create_auth_query(self): query = self.API_QUERY query['username'] = self._usr query['password'] = self._pwd return query - def runAuthQuery(self): - return self._self.load(self.API_URL, post=self.createAuthQuery(), req=req) + def run_auth_query(self): + return self._self.load(self.API_URL, post=self.create_auth_query(), req=req) -- cgit v1.2.3 From d2e2b127651a5a44b56337eb6d9ca246c97a208a Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Jul 2015 03:03:26 +0200 Subject: Spare fixes and code cosmetics --- module/plugins/accounts/RapideoPl.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 1f4140846..173b29308 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -78,4 +78,6 @@ class RapideoPl(Account): def run_auth_query(self): - return self._self.load(self.API_URL, post=self.create_auth_query(), req=req) + return self.load(self.API_URL, + post=self.create_auth_query(), + req=req) -- cgit v1.2.3 From 1f5a55ae2133a782bdcca334ecbcdbde50dbcf99 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 17 Jul 2015 15:29:48 +0200 Subject: No more need to use the req argument when call load method --- module/plugins/accounts/RapideoPl.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 173b29308..5183bfd7e 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -79,5 +79,4 @@ class RapideoPl(Account): def run_auth_query(self): return self.load(self.API_URL, - post=self.create_auth_query(), - req=req) + post=self.create_auth_query()) -- cgit v1.2.3 From d38e830b7c0b3c6561a0072c74bbccb5fcdf4a61 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sun, 19 Jul 2015 14:43:42 +0200 Subject: New __status__ magic key --- module/plugins/accounts/RapideoPl.py | 1 + 1 file changed, 1 insertion(+) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 5183bfd7e..d1ad6905b 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -12,6 +12,7 @@ class RapideoPl(Account): __name__ = "RapideoPl" __type__ = "account" __version__ = "0.03" + __status__ = "stable" __description__ = "Rapideo.pl account plugin" __license__ = "GPLv3" -- cgit v1.2.3 From 94d017cd2a5c1f194960827a8c7e46afc3682008 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Fri, 24 Jul 2015 06:55:49 +0200 Subject: Hotfixes (2) --- module/plugins/accounts/RapideoPl.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index d1ad6905b..30b7029ed 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -12,7 +12,7 @@ class RapideoPl(Account): __name__ = "RapideoPl" __type__ = "account" __version__ = "0.03" - __status__ = "stable" + __status__ = "testing" __description__ = "Rapideo.pl account plugin" __license__ = "GPLv3" -- cgit v1.2.3 From 8f17f875f6e28f73ddb10da59c6464bd04922222 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Jul 2015 04:59:27 +0200 Subject: Account rewritten --- module/plugins/accounts/RapideoPl.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 30b7029ed..6e2c0a134 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -32,7 +32,7 @@ class RapideoPl(Account): _pwd = None - def load_account_info(self, name, req): + def parse_info(self, name, req): self._req = req try: result = json_loads(self.run_auth_query()) @@ -54,18 +54,18 @@ class RapideoPl(Account): 'premium' : premium } - def login(self, user, data, req): + def login(self, user, password, data, req): self._usr = user - self._pwd = hashlib.md5(data['password']).hexdigest() + self._pwd = hashlib.md5(password).hexdigest() self._req = req try: response = json_loads(self.run_auth_query()) except Exception: - self.wrong_password() + self.fail() if "errno" in response.keys(): - self.wrong_password() + self.fail() data['usr'] = self._usr data['pwd'] = self._pwd -- cgit v1.2.3 From a95c217627a1cb651b24e69f20640df40797aff9 Mon Sep 17 00:00:00 2001 From: Walter Purcaro Date: Sat, 25 Jul 2015 09:34:18 +0200 Subject: Account rewritten (2) --- module/plugins/accounts/RapideoPl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/accounts/RapideoPl.py') diff --git a/module/plugins/accounts/RapideoPl.py b/module/plugins/accounts/RapideoPl.py index 6e2c0a134..42d084bdb 100644 --- a/module/plugins/accounts/RapideoPl.py +++ b/module/plugins/accounts/RapideoPl.py @@ -62,10 +62,10 @@ class RapideoPl(Account): try: response = json_loads(self.run_auth_query()) except Exception: - self.fail() + self.login_fail() if "errno" in response.keys(): - self.fail() + self.login_fail() data['usr'] = self._usr data['pwd'] = self._pwd -- cgit v1.2.3