添加云控上传失败判断
parent
50b8d2d769
commit
962e180bcd
|
|
@ -440,9 +440,18 @@ def update_main_level_db(platform, mode):
|
|||
# 更新Remote Config
|
||||
condition = config.remote_condition_android if platform == "Android" else config.remote_condition_ios
|
||||
value = f"{config.cdn}/Configs/{config_json_filename}?generation={generation}"
|
||||
firebase_helper.update_remote_config(None, condition, config.remote_key_main_db,
|
||||
|
||||
# 检查上传结果
|
||||
upload_success = firebase_helper.update_remote_config(None, condition, config.remote_key_main_db,
|
||||
f"main_{mode}", value)
|
||||
return value,level_count
|
||||
if not upload_success:
|
||||
error_msg = f"上传 Remote Config 到 Firebase 失败: platform={platform}, mode={mode}"
|
||||
print(error_msg)
|
||||
config.notification_helper.append_msg(error_msg)
|
||||
raise Exception(error_msg)
|
||||
else:
|
||||
config.notification_helper.append_msg(f"成功上传 Remote Config: platform={platform}, mode={mode}, 关卡数={level_count}")
|
||||
return value, level_count
|
||||
|
||||
|
||||
def update_main_country_level_db(platform, mode, all_country_list):
|
||||
|
|
|
|||
|
|
@ -218,6 +218,10 @@ class FirebaseHelper:
|
|||
## sub_key 该云控里面的json的某个参数的key
|
||||
try:
|
||||
etag = self.get_remote_value()
|
||||
if etag is None:
|
||||
print("获取 ETag 失败,无法更新 Remote Config")
|
||||
return False
|
||||
|
||||
online_txt = ""
|
||||
with open(REMOTE_CONFIG_FILE, "r") as f:
|
||||
online_txt = f.read()
|
||||
|
|
@ -251,10 +255,18 @@ class FirebaseHelper:
|
|||
print("\n\n")
|
||||
# 将online_json写入到remote_config.json文件
|
||||
utils.write_json(REMOTE_CONFIG_FILE, online_json)
|
||||
self.upload_remote_config_value(etag)
|
||||
|
||||
# 检查上传结果
|
||||
upload_success = self.upload_remote_config_value(etag)
|
||||
if upload_success:
|
||||
print(f"Remote Config 更新成功: {main_key}/{sub_key}")
|
||||
return True
|
||||
else:
|
||||
print(f"Remote Config 更新失败: {main_key}/{sub_key}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(e)
|
||||
raise Exception("更新失败")
|
||||
print(f"更新 Remote Config 异常: {repr(e)}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
helper = FirebaseHelper()
|
||||
|
|
@ -264,5 +276,3 @@ if __name__ == "__main__":
|
|||
# print(blob2 is None)
|
||||
etag = helper.get_remote_value()
|
||||
print(etag)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue