-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
203 lines (162 loc) · 8.89 KB
/
Copy pathtest.py
File metadata and controls
203 lines (162 loc) · 8.89 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
import time
import os
import pyautogui
import datetime
from PIL import ImageGrab
from numpy import *
import csv
'''
def leftClick(x, y):
pyautogui.click(x, y)
time.sleep(1)
# calendario inicio
leftClick(193, 507)
time.sleep(2)
# flecha atras
leftClick(198, 510)
time.sleep(2)
'''
import os
CalendarCordSMU = {'1': (195, 556, 212, 569), # linea 1
'2': (220, 556, 237, 569),
'3': (244, 556, 261, 569),
'4': (269, 556, 286, 569),
'5': (293, 556, 310, 569),
'6': (318, 556, 335, 569),
'7': (343, 556, 360, 569),
'8': (195, 579, 212, 592), # linea 2
'9': (220, 579, 237, 592),
'10': (244, 579, 261, 592),
'11': (269, 579, 286, 592),
'12': (293, 579, 310, 592),
'13': (318, 579, 335, 592),
'14': (343, 579, 360, 592),
'15': (195, 602, 212, 615), # linea 3
'16': (220, 602, 237, 615),
'17': (244, 602, 261, 615),
'18': (269, 602, 286, 615),
'19': (293, 602, 310, 615),
'20': (318, 602, 335, 615),
'21': (343, 602, 360, 615),
'22': (195, 625, 212, 637), # linea 4
'23': (220, 625, 237, 637),
'24': (244, 625, 261, 637),
'25': (269, 625, 286, 637),
'26': (293, 625, 310, 637),
'27': (318, 625, 335, 637),
'28': (343, 625, 360, 637),
'29': (195, 648, 212, 660), # linea 5
'30': (220, 648, 237, 660),
'31': (244, 648, 261, 660),
'32': (269, 648, 286, 660),
'33': (293, 648, 310, 660),
'34': (318, 648, 335, 660),
'35': (343, 648, 360, 660),
'36': (195, 671, 212, 683), # linea 6
'37': (220, 671, 237, 683),
'38': (244, 671, 261, 683),
'39': (269, 671, 286, 683),
'40': (293, 671, 310, 683),
'41': (318, 671, 335, 683),
'42': (343, 671, 360, 683),
}
for k, v in sorted(CalendarCordSMU.items(), key=lambda x:int(x[0]), reverse=True):
print(k + str(v))
#print(CalendarCordSMU.get('box2')[1])
#mapeo = [open('mapeo_pix/' + str(i) + '.txt', 'r') for i in range(1, 43)]
#corpus = [doc.read() for doc in mapeo]
#print(corpus[1])
from pyunpack import Archive
now = datetime.datetime.now()
ruta_archivo_cenco = 'M:\WebBot\Cenco'
Archive(ruta_archivo_cenco + '\\archivo_' + str(now.date()) + '.rar').extractall(ruta_archivo_cenco)
for file in os.listdir(ruta_archivo_cenco):
if file.endswith(".csv"):
os.rename(os.path.join(ruta_archivo_cenco, file), os.path.join(ruta_archivo_cenco, 'datos.csv'))
'''
quitar1 = '(168, 198, 238), '
quitar2 = ', (168, 198, 238)'
aa = [(168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (91, 95, 106), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (131, 149, 175), (64, 58, 58), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (150, 172, 206), (64, 58, 58), (131, 149, 175), (150, 172, 206), (150, 172, 206), (150, 172, 206), (150, 172, 206), (150, 172, 206), (150, 172, 206), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (64, 58, 58), (64, 58, 58), (64, 58, 58), (64, 58, 58), (64, 58, 58), (64, 58, 58), (64, 58, 58), (64, 58, 58), (64, 58, 58), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238), (168, 198, 238)]
paso1 = str(aa).replace(quitar1, '')
paso2 = paso1.replace(quitar2, '')
print(paso2)
print('\n\n\n')
archivo = "C:\WebBot\SMU\Ventas(Producto)_13-12-2018_170909.csv"
texto = "C:\WebBot\SMU\Ventas(Producto)_13-12-2018_170909.txt"
import codecs
try:
with codecs.open(archivo, 'rU', 'utf-8') as csvfile:
spamreader = csv.reader(csvfile)
for row in spamreader:
print(','.join(row))
except Exception as e:
print(e)
pass
'''
'''
import os
ruta_archivo_smu = 'C:\WebBot\Cenco'
file_path = 'C:\WebBot\Cenco'
for file in os.listdir(file_path):
if file.endswith(".csv"):
print('a')
print(os.path.join(file_path, file))
'''
'''
import shutil
print("moviendo")
shutil.move('C:/Users/smunoz/Downloads/datos.csv', 'C:/WebBot/Tottus/datos.csv')
'''
'''
coord_x1 = 1059
coord_y1 = 348
coord_x2 = 1076
coord_y2 = 358
cont = 1
lista = {}
for x in range(6):
for y in range(7):
print(coord_x1, coord_y1, coord_x2, coord_y2)
li = {str(cont): (coord_x1, coord_y1, coord_x2, coord_y2)}
lista.update(li)
cont += 1
coord_x1 += 28
coord_x2 += 28
coord_x1 = 1059
coord_x2 = 1076
coord_y1 += 17
coord_y2 += 17
print(lista)
import datetime
now = datetime.datetime.now()
quitar_blanco1 = '(255, 255, 255), '
quitar_blanco2 = ', (255, 255, 255)'
quitar_azul1 = '(168, 198, 238), '
quitar_azul2 = ', (168, 198, 238)'
# recibe box=(x1, y1, x2, y2)
def screenGrab(box):
im = ImageGrab.grab(box)
im.save(os.getcwd() + '\\img\\test\\tottus' + str(now.date()) + str(box) + '.png', 'PNG')
return im
time.sleep(5)
blanco = (255, 255, 255)
blanco1 = (250, 250, 250)
for k, v in lista.items():
#text = open(k + '.txt', 'w')
im = screenGrab(v)
pix = [im.getpixel((x, y)) for x in range(0, v[2] - v[0]) for y in range(0, v[3] - v[1])]
for pos in range(len(pix)):
if pix[pos] == blanco:
pix[pos] = blanco1
if pix[pos] != blanco1:
pix[pos] = (0, 0, 0)
#text.write(str(pix))
#text.close()
print(k)
'''
'''
from pyunpack import Archive
ruta_archivo_smu = 'C:\WebBot\SMU'
now = datetime.datetime.now()
Archive(ruta_archivo_smu + '\\archivo_' + str(now.date()) + '.rar').extractall(ruta_archivo_smu)
'''