python 自动签名并安装

1. python 自动签名并安装

import subprocess
import shutil
from  xml.dom import  minidom
import zipfile 
import os
import re
import glob
import sys
import codecs
import random
import string
import time

def main(filepath = None):
    if filepath:
        input_filename = filepath
    else:
        input_filename = sys.argv[1]
    shutil.copyfile(input_filename, 'forsign.apk')
    print 'file_name in : ' + input_filename
    output_filename = 'signed_' + input_filename
    subprocess.Popen('java -jar signapk.jar testkey.x509.pem testkey.pk8 forsign.apk ' + output_filename, stdout=subprocess.PIPE).stdout.read()
    print 'file_name : ' + output_filename
    subprocess.Popen('adb install -t ' + output_filename, stdout=subprocess.PIPE).stdout.read()
    os.remove('forsign.apk')
    
if __name__ == '__main__':
    start = time.time()
    main()
    end = time.time()
    print "Total time running %s seconds" %(str(end - start))

2. bat 一键执行

先生成 bat 文件,在运行前先改名为 debug.apk。双击 sign.bat

@echo off
set PATH=%CD%;%PATH%;
python "%~dp0\sign.py" debug.apk

你可能感兴趣的:(python 自动签名并安装)