Last active
August 2, 2019 01:33
-
-
Save fushenghua/7091d959d94e0f96eb8b3a6a7355441b to your computer and use it in GitHub Desktop.
360自动加固Android APK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import os | |
import shutil | |
import subprocess | |
def startJIAGU(): | |
WORKSPACE= os.getenv("WORKSPACE")+"\\" | |
JIAGU_HOME= os.getenv("JIAGU_HOME") | |
isPublish = open(WORKSPACE+"isPublish.txt").readline().strip('\n').rstrip()+"" | |
# print "isPublish ="+isPublish | |
print WORKSPACE | |
if cmp(isPublish,"true")==0 : | |
print "start JIAGU .." | |
version = open(WORKSPACE+"version.txt") | |
release ="D:\\Android\\release\\"+version.readline().strip('\n') | |
version.close | |
print "release path ->%s" % release | |
if not os.path.isdir(release): | |
os.makedirs(release) | |
else: | |
shutil.rmtree(release) | |
for retry in range(10): | |
try: | |
os.makedirs(release) | |
break | |
except: | |
print "makedirs failed, retrying..." | |
command ="java -jar %s\\jiagu.jar -jiagu %sapp\\build\\outputs\\apk\\release\\*_release.apk %s -autosign -automulpkg"%(JIAGU_HOME,WORKSPACE,release) | |
print command | |
print bash_shell(command) | |
print "JIAGU SUCCESS path -> %s"% release | |
shutil.copytree('%sapp\\build\\outputs\\mapping\\release\\'%WORKSPACE, release+"\\mapping\\") | |
shutil.copytree('%sapp\\build\\bakApk\\'%WORKSPACE, release+"\\bakApk\\") | |
else: | |
print "isPublish ->%s"% isPublish | |
def bash_shell(bash_command): | |
""" | |
python 中执行 bash 命令 | |
:param bash_command: | |
:return: bash 命令执行后的控制台输出 | |
""" | |
try: | |
# return os.popen(bash_command).read().strip() | |
subprocess.call(bash_command) | |
except Exception as ex: | |
print(ex) | |
return "error" | |
startJIAGU() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment