aboutsummaryrefslogtreecommitdiff
path: root/cgi/modapi.py
diff options
context:
space:
mode:
Diffstat (limited to 'cgi/modapi.py')
-rw-r--r--cgi/modapi.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/cgi/modapi.py b/cgi/modapi.py
index 7bb63fb..499535e 100644
--- a/cgi/modapi.py
+++ b/cgi/modapi.py
@@ -12,11 +12,11 @@ def api(self, path_split):
if len(path_split) > 2:
try:
self.output = api_process(self, path_split)
- except APIError, e:
+ except APIError as e:
self.output = api_error("error", e.message)
- except UserError, e:
+ except UserError as e:
self.output = api_error("failed", e.message)
- except Exception, e:
+ except Exception as e:
import sys
import traceback
exc_type, exc_value, exc_traceback = sys.exc_info()
@@ -65,11 +65,11 @@ def api_process(self, path_split):
else:
logAction('', 'Failed log-in. Username:'+_mysql.escape_string(
self.formdata['username'])+' IP:'+self.environ["REMOTE_ADDR"])
- raise APIError, "Incorrect username/password."
+ raise APIError("Incorrect username/password.")
else:
- raise APIError, "Bad request"
+ raise APIError("Bad request")
else:
- raise APIError, "Not authenticated"
+ raise APIError("Not authenticated")
else:
if method == 'news':
news = FetchAll(
@@ -77,7 +77,7 @@ def api_process(self, path_split):
values['news'] = news
elif method == 'post':
board = setBoard(formdata.get("board"))
- if 'id' in formdata.keys():
+ if 'id' in formdata:
id = formdata.get('id')
post = FetchOne("SELECT `id`, `boardid`, `parentid`,`timestamp`, `name`, `tripcode`, `email` ,`subject`,`message`,`file`,`thumb`, INET6_NTOA(`ip`) as ip,`IS_DELETED` AS `deleted`, `bumped`, `last`, `locked` FROM `posts` WHERE `id` = '" +
_mysql.escape_string(id) + "' AND `boardid` = '" + _mysql.escape_string(board["id"]) + "'")
@@ -90,7 +90,7 @@ def api_process(self, path_split):
post['timestamp'] = int(post['timestamp'])
post['boardid'] = int(post['boardid'])
values['post'] = post
- if 'parentid' in formdata.keys():
+ if 'parentid' in formdata:
id = formdata.get('parentid')
posts = FetchAll("SELECT `id`, `boardid`, `parentid`,`timestamp`, `name`, `tripcode`, `email` ,`subject`,`message`,`file`,`thumb`, INET6_NTOA(`ip`) as ip,`IS_DELETED` AS `deleted`, `bumped`, `last`, `locked` FROM `posts` WHERE `parentid` = '" +
_mysql.escape_string(id) + "' AND `boardid` = '" + _mysql.escape_string(board["id"]) + "'")
@@ -114,28 +114,28 @@ def api_process(self, path_split):
numreplies = 2
if not data_board:
- raise APIError, "Missing parameters"
+ raise APIError("Missing parameters")
if data_limit:
try:
limit = int(data_limit)
except ValueError:
- raise APIError, "Limit must be numeric"
+ raise APIError("Limit must be numeric")
if data_offset:
try:
offset = int(data_offset)
except ValueError:
- raise APIError, "Offset must be numeric"
+ raise APIError("Offset must be numeric")
if data_replies:
try:
numreplies = int(data_replies)
except ValueError:
- raise APIError, "Replies must be numeric"
+ raise APIError("Replies must be numeric")
if data_replies and limit > 30:
- raise APIError, "Maximum limit is 30"
+ raise APIError("Maximum limit is 30")
board = setBoard(data_board)
@@ -221,10 +221,10 @@ def api_process(self, path_split):
values['stats'] = out
except ValueError:
values['stats'] = None
- raise APIError, "Stats error"
+ raise APIError("Stats error")
values['stats']['reportCount'] = report_count['COUNT(id)']
else:
- raise APIError, "Invalid method"
+ raise APIError("Invalid method")
values['time'] = int(t)
return json.dumps(values, sort_keys=True, separators=(',', ':'))
@@ -313,7 +313,7 @@ def verifyPasswd(username, passwd):
except argon2.exceptions.VerifyMismatchError:
return None
except argon2.exceptions.InvalidHash:
- raise UserError, "Hash obsoleto o inválido. Por favor contacte al administrador."
+ raise UserError("Hash obsoleto o inválido. Por favor contacte al administrador.")
if ph.check_needs_rehash(staff_account['password']):
param_new_hash = ph.hash(staff_acount['password'])