forked from gb112211/AndroidTestScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup_app.py
More file actions
36 lines (26 loc) · 838 Bytes
/
backup_app.py
File metadata and controls
36 lines (26 loc) · 838 Bytes
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
35
36
#!/usr/bin/env python
# -*- coding: utf-8 -*-
'''
Created on 2015年2月12日
@author: xuxu
'''
import os
from scriptUtils import utils
#adb backup命令可以备份,该脚本只用于备份设备上安装的第三方应用,将apk保存在当前目录下的backup_app文件夹中
PATH = lambda p : os.path.abspath(p)
def get_apk_list():
apps = []
for apk in utils.shell("pm list packages -f -3").stdout.readlines():
apps.append(apk.split(":")[-1].split("=")[0])
return apps
def backup_app():
apps = get_apk_list()
for apk in apps:
utils.adb("pull %s backup_app" %apk).wait()
print "pull %s succeed." %apk
if __name__ == "__main__":
path = PATH("%s/backup_app" %os.getcwd())
if not os.path.isdir(path):
os.mkdir(path)
backup_app()
print "Completed"