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