main.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # -*- coding:utf-8 -*-
  2. import sys, os, json, zipfile
  3. import merge_apk_v2,merge_apk, file_utils
  4. def package():
  5. if len(sys.argv) < 2:
  6. print("参数数量不正确")
  7. exit(1)
  8. config = sys.argv[1]
  9. if not os.path.exists(config):
  10. print("配置文件不存在")
  11. exit(1)
  12. apk_path = json.loads(file_utils.read_file(config))['apk_path']
  13. if real_apk_config(apk_path):
  14. print("母包接入新版SDK")
  15. ret = merge_apk_v2.startMerge(config)
  16. else:
  17. print("母包接入旧版SDK")
  18. ret = merge_apk.startMerge(config)
  19. if not ret:
  20. print("切包失败,请联系开发人员")
  21. exit(1)
  22. print("成功")
  23. exit(0)
  24. pass
  25. def real_apk_config(apk_path):
  26. if not os.path.exists(apk_path):
  27. return False
  28. z = zipfile.ZipFile(apk_path, "r")
  29. for filename in z.namelist():
  30. if filename == "assets/yyxx_game/yyxx_cfg.properties":
  31. return True
  32. return False
  33. if __name__ == "__main__":
  34. package()