对只读情况做处理
This commit is contained in:
parent
148e7e6025
commit
e9749386f5
33
config.py
33
config.py
@ -75,6 +75,7 @@ def load_config():
|
|||||||
|
|
||||||
|
|
||||||
def save_config():
|
def save_config():
|
||||||
|
global serverless
|
||||||
if not serverless:
|
if not serverless:
|
||||||
log.info("云函数执行,无法保存")
|
log.info("云函数执行,无法保存")
|
||||||
return None
|
return None
|
||||||
@ -83,16 +84,23 @@ def save_config():
|
|||||||
data["mihoyobbs_Login_ticket"] = login_ticket
|
data["mihoyobbs_Login_ticket"] = login_ticket
|
||||||
data["mihoyobbs_Stuid"] = stuid
|
data["mihoyobbs_Stuid"] = stuid
|
||||||
data["mihoyobbs_Stoken"] = stoken
|
data["mihoyobbs_Stoken"] = stoken
|
||||||
f.seek(0)
|
|
||||||
f.truncate()
|
|
||||||
temp_text = json.dumps(data, sort_keys=False, indent=4, separators=(', ', ': '))
|
temp_text = json.dumps(data, sort_keys=False, indent=4, separators=(', ', ': '))
|
||||||
f.write(temp_text)
|
try:
|
||||||
f.flush()
|
f.seek(0)
|
||||||
|
f.truncate()
|
||||||
|
f.write(temp_text)
|
||||||
|
f.flush()
|
||||||
|
except OSError:
|
||||||
|
serverless = True
|
||||||
|
log.info("Cookie保存失败")
|
||||||
|
exit(-1)
|
||||||
|
else:
|
||||||
|
log.info("Config保存完毕")
|
||||||
f.close()
|
f.close()
|
||||||
log.info("Config保存完毕")
|
|
||||||
|
|
||||||
|
|
||||||
def clear_cookies():
|
def clear_cookies():
|
||||||
|
global serverless
|
||||||
if not serverless:
|
if not serverless:
|
||||||
log.info("云函数执行,无法保存")
|
log.info("云函数执行,无法保存")
|
||||||
return None
|
return None
|
||||||
@ -103,10 +111,15 @@ def clear_cookies():
|
|||||||
data["mihoyobbs_Stuid"] = ""
|
data["mihoyobbs_Stuid"] = ""
|
||||||
data["mihoyobbs_Stoken"] = ""
|
data["mihoyobbs_Stoken"] = ""
|
||||||
data["mihoyobbs_Cookies"] = "CookieError"
|
data["mihoyobbs_Cookies"] = "CookieError"
|
||||||
f.seek(0)
|
|
||||||
f.truncate()
|
|
||||||
temp_text = json.dumps(data, sort_keys=False, indent=4, separators=(', ', ': '))
|
temp_text = json.dumps(data, sort_keys=False, indent=4, separators=(', ', ': '))
|
||||||
f.write(temp_text)
|
try:
|
||||||
f.flush()
|
f.seek(0)
|
||||||
|
f.truncate()
|
||||||
|
f.write(temp_text)
|
||||||
|
f.flush()
|
||||||
|
except OSError:
|
||||||
|
serverless = True
|
||||||
|
log.info("Cookie删除失败")
|
||||||
|
else:
|
||||||
|
log.info("Cookie删除完毕")
|
||||||
f.close()
|
f.close()
|
||||||
log.info("Cookie删除完毕")
|
|
||||||
|
6
index.py
6
index.py
@ -1,12 +1,12 @@
|
|||||||
import main
|
import main
|
||||||
import push
|
import push
|
||||||
|
import config
|
||||||
import main_multi
|
import main_multi
|
||||||
from error import CookieError
|
from error import CookieError
|
||||||
from config import serverless
|
|
||||||
|
|
||||||
|
|
||||||
def main_handler(event: dict, context: dict):
|
def main_handler(event: dict, context: dict):
|
||||||
serverless = True
|
config.serverless = True
|
||||||
try:
|
try:
|
||||||
status_code, push_message = main.main()
|
status_code, push_message = main.main()
|
||||||
except CookieError:
|
except CookieError:
|
||||||
@ -17,7 +17,7 @@ def main_handler(event: dict, context: dict):
|
|||||||
|
|
||||||
|
|
||||||
def main_handler_mulit(event: dict, context: dict):
|
def main_handler_mulit(event: dict, context: dict):
|
||||||
serverless = True
|
config.serverless = True
|
||||||
# 多用户需要传递True表示自动执行,不需要手动进行确认
|
# 多用户需要传递True表示自动执行,不需要手动进行确认
|
||||||
main_multi.main_multi(True)
|
main_multi.main_multi(True)
|
||||||
print("云函数多用户测试支持!")
|
print("云函数多用户测试支持!")
|
||||||
|
Loading…
Reference in New Issue
Block a user