| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import time
- # from venv import logger
- import redis
- from utils.helper import Helper
- from settings import R_HOST, R_PASSWORD, R_POST, R_DB, MATCH_STATUS
- def get_redis(k):
- rls = redis.Redis(host=R_HOST, port=R_POST, db=R_DB, password=R_PASSWORD)
- ids = rls.hgetall(k)
- return ids
- def Change_status(ids):
- if ids:
- for id, up_time in ids.items():
- match_id = id.decode()
- up_time = up_time.decode().split('&')
- last_time = float(up_time[0])
- game_code = up_time[1]
- new_time = time.time() - last_time
- if new_time > 900:
- status_dict = {"game_code": game_code, "title": "match_status", "source": "hg3535"}
- data_list = []
- data = {'match_id': match_id, 'status': 2, "is_rollball": 0, "is_today": 0, "is_morningplate": 0,
- "is_stringscene": 0, "is_horn": 0}
- data_list.append(data)
- status_dict['data'] = data_list
- res = Helper.async_post(MATCH_STATUS, status_dict)
- if res:
- if "成功" in res:
- # self.db.match_status35.insert(status_dict)
- print('{},赛事结果状态交成功, {}'.format(game_code, res))
- print(status_dict)
- else:
- print('{},赛事结果状态交失败, {}'.format(game_code, res))
- print(status_dict)
- else:
- print('{},赛事结果状态接口异常提交失败, {}'.format(game_code, res))
- print(status_dict)
- else:
- print('15分钟内, 暂无球类赛事结束或取消')
- if __name__ == '__main__':
- while True:
- ids = get_redis('hg3535.ball.ids')
- Change_status(ids)
- print('*****-------球类更新状态, 运行结束--------*****')
- time.sleep(30)
|