增加账号回报状态
This commit is contained in:
@@ -1,6 +1,18 @@
|
|||||||
class AuthException(Exception):
|
class BaseError(Exception):
|
||||||
|
def __init__(self, message='', error_type='failed'):
|
||||||
|
self.error_type = error_type
|
||||||
|
self.message = message
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.message
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return self.message
|
||||||
|
|
||||||
|
|
||||||
|
class AuthException(BaseError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class OperationFailed(Exception):
|
class OperationFailed(BaseError):
|
||||||
pass
|
pass
|
||||||
|
|||||||
6
main.py
6
main.py
@@ -47,12 +47,12 @@ def execute_task(tid, task_type, **kwargs):
|
|||||||
try:
|
try:
|
||||||
result = TASK_TYPE.get(task_type)(**kwargs)
|
result = TASK_TYPE.get(task_type)(**kwargs)
|
||||||
task_callback(tid, data=result)
|
task_callback(tid, data=result)
|
||||||
except AuthException as e:
|
except (AuthException, OperationFailed) as e:
|
||||||
record_full_log(error_logger, e)
|
record_full_log(error_logger, e)
|
||||||
task_callback(tid, data={}, status='fail', msg=str(e))
|
task_callback(tid, data={}, status=e.error_type, msg=str(e))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
record_full_log(error_logger, e)
|
record_full_log(error_logger, e)
|
||||||
task_callback(tid, data={}, status='fail', msg=str(e))
|
task_callback(tid, data={}, status='failed', msg=str(e))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
@@ -786,7 +786,7 @@ def check_account_status(page):
|
|||||||
# 账户被暂停
|
# 账户被暂停
|
||||||
suspended_span = page.query_selector_all('//span[text()="We suspended your account"]')
|
suspended_span = page.query_selector_all('//span[text()="We suspended your account"]')
|
||||||
if suspended_span:
|
if suspended_span:
|
||||||
raise AuthException('该账户被暂停')
|
raise AuthException('该账户被暂停', 'frozen')
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -794,7 +794,7 @@ def check_account_status(page):
|
|||||||
# 被封
|
# 被封
|
||||||
lock_img = page.query_selector_all('//img[@src="/images/checkpoint/epsilon/comet/intro.png"]')
|
lock_img = page.query_selector_all('//img[@src="/images/checkpoint/epsilon/comet/intro.png"]')
|
||||||
if lock_img:
|
if lock_img:
|
||||||
raise AuthException('该账户已被封禁')
|
raise AuthException('该账户已被封禁', 'frozen')
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -802,10 +802,10 @@ def check_account_status(page):
|
|||||||
# 无法登录 无效cookies
|
# 无法登录 无效cookies
|
||||||
login_btn = page.query_selector_all('//button[@name="login"]')
|
login_btn = page.query_selector_all('//button[@name="login"]')
|
||||||
if login_btn:
|
if login_btn:
|
||||||
raise AuthException('该账户登录状态失效')
|
raise AuthException('该账户登录状态失效', 'invalid')
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
pass
|
pass
|
||||||
raise AuthException('该账户异常')
|
raise AuthException('该账户异常', 'invalid')
|
||||||
|
|
||||||
|
|
||||||
class RLock(threading._RLock):
|
class RLock(threading._RLock):
|
||||||
|
|||||||
Reference in New Issue
Block a user