增加异常检测
parent
141043febf
commit
01719e04d3
22
main.py
22
main.py
|
|
@ -1,3 +1,5 @@
|
|||
from logging import error
|
||||
from traceback import print_tb
|
||||
import requests
|
||||
import re
|
||||
import json
|
||||
|
|
@ -211,9 +213,11 @@ class HealthCheckInHelper(ZJULogin):
|
|||
return
|
||||
except:
|
||||
print('验证码识别失败')
|
||||
raise Exception("验证码识别失败")
|
||||
except:
|
||||
print('打卡网页获取失败')
|
||||
finally:
|
||||
print('发生异常')
|
||||
raise Exception("发生异常")
|
||||
|
||||
new_info_tmp = json.loads(re.findall(r'def = ({[^\n]+})', html)[0])
|
||||
new_id = new_info_tmp['id']
|
||||
new_uid = new_info_tmp['uid']
|
||||
|
|
@ -351,6 +355,11 @@ class HealthCheckInHelper(ZJULogin):
|
|||
if self.delay_run:
|
||||
# 确保定时脚本执行时间不太一致
|
||||
time.sleep(random.randint(10, 100))
|
||||
try_count=0
|
||||
while True:
|
||||
if try_count>10:
|
||||
print("已经尝试你妈的10次了,还不对,你退群吧")
|
||||
return
|
||||
try:
|
||||
self.login()
|
||||
# 拿取eai-sess的cookies信息
|
||||
|
|
@ -363,9 +372,16 @@ class HealthCheckInHelper(ZJULogin):
|
|||
# print(geo_info)
|
||||
res = self.take_in(geo_info)
|
||||
print(res)
|
||||
return
|
||||
except requests.exceptions.ConnectionError:
|
||||
# reraise as KubeException, but log stacktrace.
|
||||
print("打卡失败,请检查github服务器网络状态")
|
||||
print("打卡失败,请检查服务器网络状态")
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print("遇到错误,尝试重试")
|
||||
print("重试中...",try_count)
|
||||
try_count+=1
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
|||
Loading…
Reference in New Issue