42 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
			
		
		
	
	
			42 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Python
		
	
	
	
import os.path
 | 
						|
 | 
						|
from scripts.task import Task
 | 
						|
from utils import FileUtils
 | 
						|
from utils.logger_utils import app_logger
 | 
						|
 | 
						|
 | 
						|
class ProjectUpdateKeystore(Task):
 | 
						|
 | 
						|
    def update_keystore(self):
 | 
						|
        if not self.context.update_keystore:
 | 
						|
            app_logger().info("No update_keystore")
 | 
						|
            return
 | 
						|
 | 
						|
        name = os.path.basename(self.context.keystore_path).replace(".keystore", "")
 | 
						|
        target_path = os.path.join(self.context.temp_project_path, name + ".keystore")
 | 
						|
 | 
						|
        if os.path.exists(target_path):
 | 
						|
            os.remove(target_path)
 | 
						|
 | 
						|
        result = FileUtils.copy(self.context.keystore_path, target_path)
 | 
						|
 | 
						|
        app_logger().debug(f"copy keystore result {result}")
 | 
						|
 | 
						|
        target_path = os.path.join(self.context.temp_project_path, "keystore.properties")
 | 
						|
        if os.path.exists(target_path):
 | 
						|
            os.remove(target_path)
 | 
						|
 | 
						|
        open(target_path, "w", encoding="utf-8").write(
 | 
						|
            f"""
 | 
						|
keyAlias={name}
 | 
						|
keyPassword=123456
 | 
						|
storeFile=./{name}.keystore
 | 
						|
storePassword=123456
 | 
						|
"""
 | 
						|
        )
 | 
						|
 | 
						|
    def execute(self):
 | 
						|
        self.update_keystore()
 | 
						|
        self.context.save_cache_config("keystore", self.context.config_keystore_md5)
 | 
						|
        pass
 |