def apk_image_check(check_alpha=True, limit=40000, apk=None, ignore9=True, value=255): if apk is None: print("invalid apk file or name") exit() utils.check_apk_name_valid(apk) print("apk:" + apk) # 获取没有拓展名的文件名 apk_dir = os.path.split(apk)[-1].split(".")[0] # 解压文件夹以便分析 print("start to unzip apk") utils.surely_rmdir(apk_dir) utils.unzip_dir(apk, apk_dir) if limit is not None: print("") print("============ check size limit =================="); check_image_limit(apk, apk_dir, limit) print("============ check size limit =================="); if check_alpha: print("") print("") print("============ check image alpha =================="); check_apk_alpha(apk, apk_dir, ignore9, value) print("============ check image alpha =================="); print("") # 移除分析用的解压出来的文件 utils.surely_rmdir(apk_dir)
# check all param for opt, arg in opts: if opt in ("-h", "--help"): usage(); sys.exit(1); if opt in ("-s", "--single"): apk_single = arg if opt in ("-o", "--old"): apk_old = arg if opt in ("-n", "--new"): apk_new = arg if opt in ("-t", "--top"): top = arg except getopt.GetoptError, e: print("getopt error! " + e.msg); exit() if apk_single is not None: print("apk_single valid, -o and -n will be ignored"); # 检查单个 utils.check_apk_name_valid(apk_single) get_apk_data(apk_single) elif apk_new is None or apk_old is None: print("invalid input! Able to check if valid args with -o and -n or -s"); exit() else: utils.check_apk_name_valid(apk_new) utils.check_apk_name_valid(apk_old) compare_apk(apk_old, apk_new, top)