-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbacknote4.py
48 lines (29 loc) · 1.21 KB
/
backnote4.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
35
36
37
38
39
40
41
42
43
44
45
46
47
import subprocess
import os
# python solution was devised because some characters in note4 path made sh fail sometimes
remoteSource='/storage/9C33-6BBD/Android/data/zaza.stable/files'
localTarget='/cygdrive/c/Users/thomas/Dropbox/current_zazanim_projects/macumba'
#localTarget='/cygdrive/c/tmp/zazexport'
def pullframes(files):
os.chdir(localTarget)
#result=subprocess.run(['adb','pull','-p',remoteSource+'/'+frames[0]])
#print(result)
for frame in files :
print("file to pull :"+frame)
result=subprocess.run(['adb','pull',remoteSource+'/'+frame])
print(result)
result=subprocess.run(['adb','shell','ls',remoteSource],stdout=subprocess.PIPE)
print(result.stdout)
frames=result.stdout.decode('utf-8').splitlines()
print(frames)
filteredFrames=[]
#filtering empty lines created by parsing return of adb ls
for frame in frames:
if frame:#not empty
filteredFrames.append(frame)
print('filtered frames:')
print(filteredFrames)
pullframes(filteredFrames)
#subprocess.run(['cd',localTarget],stdout=subprocess.PIPE)
#specifying target files fails (maybe because I pass cygwin path )
#result=subprocess.run(['adb','pull','-p',remoteSource+'/'+frames[0],localTarget+'/'+frames[0]])