-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfiles.py
68 lines (54 loc) · 1.86 KB
/
files.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
from py_adb.adb import ADB
import os
class Files:
@staticmethod
def pull(dev_id: str, path_from: str, path_to: str):
"""
Print ADB pull execution into terminal
:dev_id: device id
:path_from: Path to file on the device
:path_to: Path to save a file
"""
command = "adb -s {dev_id} pull {path_from} {path_to}".format(
dev_id=dev_id, path_from=path_from, path_to=path_to)
output = ADB.get_terminal_output(command)
print("I: {}".format(output))
@staticmethod
def push(dec_id: str, path_file: str, path_to: str):
"""
Print ADB push execution into terminal
:dev_id: device id
:path_file: Path to file
:path_to: Path to save file in the device
TODO: Check File existance before push
TODO: Test
"""
command = "adb -s {dev} push {path_file} {path_to}".format(dev=dec_id, path_file=path_file, path_to=path_to)
output = ADB.get_terminal_output(command)
print("I: {}".format(output))
@staticmethod
def delete(dev_id: str, path_file: str):
"""
Method to delete file a device
:dev_id: Device ID
:path_file: Path to file
"""
command = "adb -s {dev} shell rm {path}".format(dev=dev_id, path=path_file)
ADB.exec_adb(command)
@staticmethod
def clear_dir(path: str):
"""
Method to clear all files in the dir
"""
assert os.path.isdir(path)
files = os.listdir(path)
for f in files:
if os.path.isfile(os.path.join(path, f)):
os.remove(os.path.join(path, f))
@staticmethod
def gen_file_name(cur_activity=True) -> str:
"""
Method to generate file name
TODO: Find Better approach
"""
return "display_layout.xml"