-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathinstall_apk.py
34 lines (31 loc) · 1006 Bytes
/
install_apk.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import pipes
import sys
from toolchain import run_script
from commands import CMD_INSTALL_APP
apkFiles = os.getenv('apkFile').split("\t")
options = os.getenv('option')
optionArg = ""
if options:
for option in options:
if option and option.strip():
optionArg = optionArg + " -" + option
try:
if apkFiles:
totalFiles = len(apkFiles)
installResults = 0
sys.stderr.write("Step 1 {0}\n".format(totalFiles))
for apkFile in apkFiles:
sys.stderr.write("Step 2" + "\n")
if not apkFile:
continue
result = run_script(CMD_INSTALL_APP.format(optionArg, (pipes.quote(apkFile), apkFile)[apkFile.startswith('\"') or apkFile.startswith("\'")]))
if "Failure [" not in result and "Error:" not in result:
installResults = installResults + 1
sys.stderr.write(result + "\n")
if installResults == totalFiles:
print("Install app succeed")
else:
print("Install app failed, {0}/{1} failed".format(totalFiles - installResults, totalFiles))
except:
print("Install app failed")