|
@@ -246,7 +246,6 @@ class get_scan_status(BaseHandler):
|
|
|
|
|
|
# TODO:wechat_info,human_info 这两张表有空时需要进行对应改进
|
|
|
class ad_human_info(BaseHandler):
|
|
|
- # TODO:设置一下update---table,如果失败了sql_session需要关闭
|
|
|
@staticmethod
|
|
|
def refresh_wechat_cookies(tornado_web, user_id):
|
|
|
# 1.返回二维码链接
|
|
@@ -299,27 +298,29 @@ class ad_human_info(BaseHandler):
|
|
|
# TODO:一个涉及到selenium-driver的请求-生命周期.----看一下tornado是怎么处理请求的生命周期
|
|
|
if int(is_refresh) == 1:
|
|
|
log_ad, cookie_canuse = self.refresh_wechat_cookies(self, user_id=user_id)
|
|
|
- task_name = 'user_id: {user_id} time:{time_sign} action:refresh_wechat_info'.format(
|
|
|
- user_id=user_id,
|
|
|
- time_sign=datetime.now().strftime(
|
|
|
- "%Y-%m-%d, %H:%M:%S"))
|
|
|
- # 行为记录
|
|
|
- action_type = refresh_wechat_action
|
|
|
- object_name = ''
|
|
|
- service_name = ''
|
|
|
- wechat_name = ''
|
|
|
- action_info = {'user_id': user_id, 'service_name': service_name, 'wechat_name': wechat_name,
|
|
|
- 'action_type': action_type, 'object_name': object_name, 'task_name': task_name,
|
|
|
- 'status': 'todo'}
|
|
|
- record_insert = sql_tools.save_action_record(action_record_info=action_info,
|
|
|
- table_action_record=action_record_table)
|
|
|
- sql_session.execute(record_insert)
|
|
|
- sql_session.commit()
|
|
|
+
|
|
|
if not create_ad_plan.check_task(user_id=user_id):
|
|
|
+ task_name = 'user_id: {user_id} time:{time_sign} action:refresh_wechat_info'.format(
|
|
|
+ user_id=user_id,
|
|
|
+ time_sign=datetime.now().strftime(
|
|
|
+ "%Y-%m-%d, %H:%M:%S"))
|
|
|
+ # 行为记录
|
|
|
+ action_type = refresh_wechat_action
|
|
|
+ object_name = ''
|
|
|
+ service_name = ''
|
|
|
+ wechat_name = ''
|
|
|
+ action_info = {'user_id': user_id, 'service_name': service_name, 'wechat_name': wechat_name,
|
|
|
+ 'action_type': action_type, 'object_name': object_name, 'task_name': task_name,
|
|
|
+ 'status': 'todo'}
|
|
|
+ record_insert = sql_tools.save_action_record(action_record_info=action_info,
|
|
|
+ table_action_record=action_record_table)
|
|
|
+ sql_session.execute(record_insert)
|
|
|
+ sql_session.commit()
|
|
|
threading.Thread(target=user_action.get_human_info,
|
|
|
args=(
|
|
|
user_id, log_ad, db, cookie_canuse, task_name)).start()
|
|
|
else:
|
|
|
+ logging.info('任务有堆积')
|
|
|
return
|
|
|
self.write({'status': {'msg': '任务有堆积', "RetCode": 200}})
|
|
|
else:
|
|
@@ -438,23 +439,23 @@ class ad_wechat_info(BaseHandler):
|
|
|
if int(is_refresh) == 1:
|
|
|
# 检查有无其他任务在处理中,有则等待
|
|
|
log_ad, cookie_canuse = ad_human_info.refresh_wechat_cookies(self, user_id=user_id)
|
|
|
- task_name = 'user_id: {user_id} time:{time_sign} action:refresh_wechat_info'.format(
|
|
|
- user_id=user_id,
|
|
|
- time_sign=datetime.now().strftime(
|
|
|
- "%Y-%m-%d, %H:%M:%S"))
|
|
|
- # 行为记录
|
|
|
- action_type = refresh_wechat_action
|
|
|
- object_name = ''
|
|
|
- service_name = ''
|
|
|
- wechat_name = ''
|
|
|
- action_info = {'user_id': user_id, 'service_name': service_name, 'wechat_name': wechat_name,
|
|
|
- 'action_type': action_type, 'object_name': object_name, 'task_name': task_name,
|
|
|
- 'status': 'todo'}
|
|
|
- record_insert = sql_tools.save_action_record(action_record_info=action_info,
|
|
|
- table_action_record=action_record_table)
|
|
|
- sql_session.execute(record_insert)
|
|
|
- sql_session.commit()
|
|
|
if not create_ad_plan.check_task(user_id=user_id):
|
|
|
+ task_name = 'user_id: {user_id} time:{time_sign} action:refresh_wechat_info'.format(
|
|
|
+ user_id=user_id,
|
|
|
+ time_sign=datetime.now().strftime(
|
|
|
+ "%Y-%m-%d, %H:%M:%S"))
|
|
|
+ # 行为记录
|
|
|
+ action_type = refresh_wechat_action
|
|
|
+ object_name = ''
|
|
|
+ service_name = ''
|
|
|
+ wechat_name = ''
|
|
|
+ action_info = {'user_id': user_id, 'service_name': service_name, 'wechat_name': wechat_name,
|
|
|
+ 'action_type': action_type, 'object_name': object_name, 'task_name': task_name,
|
|
|
+ 'status': 'todo'}
|
|
|
+ record_insert = sql_tools.save_action_record(action_record_info=action_info,
|
|
|
+ table_action_record=action_record_table)
|
|
|
+ sql_session.execute(record_insert)
|
|
|
+ sql_session.commit()
|
|
|
threading.Thread(target=user_action.get_human_info,
|
|
|
args=(
|
|
|
user_id, log_ad, db, cookie_canuse, task_name)).start()
|