import os import shutil from scripts.task import Task from utils import FileUtils from utils.logger_utils import app_logger class ProjectUpdateIcon(Task): def update_icon(self): """ 更新游戏Icon :return: """ if not self.context.update_res_icon: app_logger().info("No update res icon found") return tag = "res_icon_resources" dst = os.path.join(self.context.temp_project_path, tag) if os.path.exists(dst): shutil.rmtree(dst) FileUtils.decompress(self.context.res_icon_path, dst) for root, dirs, files in os.walk(dst): for file in files: temp_tart_path = os.path.join(root, file) if temp_tart_path.find("__MACOSX") > 0: continue temp_dst = temp_tart_path.replace(tag, "launcher-game" + os.sep + "res") app_logger().debug(f"copy icon = {temp_tart_path} -> {temp_dst}") FileUtils.copy(temp_tart_path, temp_dst, True) pass def execute(self): self.update_icon() self.context.save_cache_config("res_icon", self.context.config_res_icon_md5)