-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadb-tree-directory.py
70 lines (59 loc) · 1.54 KB
/
adb-tree-directory.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
import datetime
from adb_shell.adb_device import AdbDeviceTcp
from pprint import pprint as pp
import time as time
import signal
device = AdbDeviceTcp("adbaby.sstf.site", 6666, default_transport_timeout_s=10)
device.connect()
#Close session
def handler(signum, frame):
print(1)
raise Exception('Action took too much time')
signal.signal(signal.SIGALRM, handler)
signal.alarm(3) #Set the parameter to the amount of seconds you want to wait
def explore(path):
fs = device.list(path)
output = fs
if output:
headers = ('Name', 'Mode', 'Size', 'Modification Time')
# param = oct(output[0][1])
# pp(param)
signal.signal(signal.SIGALRM, handler)
signal.alarm(3) #Set the parameter to the amount of seconds you want to wait
try:
data = list()
except:
return 0
signal.alarm(3) #Resets the alarm to 10 new seconds
signal.alarm(0) #Disables the alarm
for entry in sorted(output):
# timestamp = datetime.datetime.fromtimestamp(entry[3])
timestamp = entry[3]
data.append((entry[0].decode(), oct(entry[1])[2:], str(entry[2]), timestamp))
# pp(data)
# print_table(f"Directory fs", headers, *data)
return data
else:
return 0
# pp(explore("."))
kotak = []
sudah = []
data = explore("/dev")
for i in data:
if(i[0] == "." or i[0] == ".."):
continue
kotak.append(i[0])
sudah.append(".")
while True:
if(kotak == []):
break
cari = kotak.pop()
print (cari)
data = explore(cari)
if(data == 0):
continue
for i in data:
if(i[0] == "." or i[0] == ".."):
continue
kotak.append(cari+"/"+i[0])