Repository navigation
Expand file tree
/
Copy pathAndroid.py
More file actions
129 lines (103 loc) · 3.53 KB
/
Copy pathAndroid.py
File metadata and controls
129 lines (103 loc) · 3.53 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import tkinter as tk
from tkinter import ttk
import os
import subprocess
import sys
import threading
def proceso():
print("Desactivando Suspension")
os.system(dir2+" shell svc power stayon true")
print("Listo")
print("Comenzando Instalacion: ")
filtered = [x for x in apks if ".apk" in x]
count = 0
countP = 0
text.set("Instalacion en progreso")
for x in filtered:
print(str(len(filtered)-count)+" Programas por instalar")
print("Instalando "+x)
try:
r =subprocess.check_output([dir2,"install",os.path.join(dirapk,x)], shell=False)
color.config(bg="green", fg="white")
textProceso.set(x+" instalado")
except:
color.config(bg="red",fg="white")
textProceso.set("Error "+x)
count += 1
countP += 1
print(int((100.0*countP)/len(filtered)))
progress['value'] = int((100.0*countP)/len(filtered))
screen.update_idletasks()
color.config(bg="white")
textProceso.set("")
if count == 0:
text.set("Proceso terminado")
color2.config(bg="green")
else:
text.set("Proceso terminado con errores: "+str(count))
color2.config(bg="red")
print("Listo!")
sys.stdout = sys.__stdout__
kill()
def Check():
s = subprocess.check_output([dir2,"devices"], shell=False)
lista = s.decode("utf-8").split()
if "device" in lista:
text.set("Dispositivo Encontrado")
else:
text.set("Dispositivo No Encontrado")
def kill():
command = '''kill -9 `pgrep -f fork-server`'''
os.system(command)
print("cerrado")
def threadProxy():
thread = threading.Thread(target=proceso)
thread.daemon = True
thread.start()
def register(direct):
global dir1, dir2, dirapk,apks
dirapk = os.path.join(direct,"apk")
dir1 = os.listdir(dirapk)
dir2 = os.path.join(direct,"platform-tools","adb")
dir1 = os.listdir(dirapk)
apks = []
for x in dir1:
s = x.split()
if len(s)>1:
new = "_".join(s)
os.rename(os.path.join(dirapk,x),os.path.join(dirapk,new))
apks.append(new)
else:
apks.append(x)
global screen,text,textProceso,color,color2,progress
screen = tk.Tk()
s = ttk.Style(screen)
text = tk.StringVar()
textProceso = tk.StringVar()
s.theme_use('clam')
s.configure('TButton', background = "white",borderwidth=0)
s.configure('TLabel', background = "white",borderwidth=0)
screen.title("APK")
screen.geometry("400x450")
compra = tk.PhotoImage(file = r"images/boton.png")
startimg = tk.PhotoImage(file = r"images/START.png")
salirImg = tk.PhotoImage(file = r"images/salir.png")
start = ttk.Button(screen, image = startimg, command = Check )
start.image = startimg
start.pack()
Bcompra = ttk.Button(screen, image = compra, command = threadProxy )
Bcompra.image = compra
Bcompra.pack()
emergencia = ttk.Button(screen, image = salirImg, command = kill )
emergencia.image = salirImg
emergencia.pack()
color2 = tk.Label(screen, textvariable=text)
color2.pack(pady=3)
color = tk.Label(screen, textvariable=textProceso)
color.pack(pady=3)
progress = ttk.Progressbar(screen, orient = tk.HORIZONTAL,
length = 100, mode = 'determinate')
progress.pack(pady=3)
screen.mainloop()