-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBot.py
More file actions
776 lines (679 loc) · 21.7 KB
/
Copy pathBot.py
File metadata and controls
776 lines (679 loc) · 21.7 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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
import time
import os
import pyautogui
import datetime
import shutil
import schedule
import csv
#import pyodbc
from PIL import ImageGrab
from numpy import *
from selenium import webdriver
from pyunpack import Archive
#conn = pyodbc.connect('DRIVER={SQL Server};SERVER=vsr-sqlbi;DATABASE=B2B;UID=B2B_Log_User;PWD=LUE$%2019')
ruta_descarga = 'C:\\Users\\smunoz\\Downloads'
pyautogui.FAILSAFE = False # disables the fail-safe, evita que el mouse se vaya a la esquina superior izquierda al estar el pc inactivo
# driver de INTERNET EXPLORER
ie_driver = "C:\\Users\\smunoz\\Documents\\Python\\WebBot\\IEDriverServer.exe"
chrome_driver = "C:\\Users\\smunoz\\Documents\\Python\\WebBot\\chromedriver.exe"
## PARAMETROS CONFIGURABLES ##
# MODIFICAR SOLO LO ESCRITO EN EL MANUAL #
# datos SMU
user_smu = '17596472-K'
pass_smu = 'Rita2021'
url_smu = 'https://b2b.smu.cl//Supermercados/BBRe-commerce/access/login.do'
ruta_archivo_smu = 'M:\WebBot\SMU'
ruta_pix_smu = 'mapeo_pix_smu/'
# datos Cencosud
user_cenco = '141667963'
pass_cenco = 'Rita2021'
url_cenco = 'https://www.cenconlineb2b.com/'
ruta_archivo_cenco = 'M:\WebBot\Cenco'
ruta_pix_cenco = 'mapeo_pix_cenco/'
# datos Tottus
rut_empresa = '86547900k'
user_tottus = '141667963'
pass_tottus = 'Rita2019'
url_tottus = 'https://b2b.tottus.com/b2btoclpr/grafica/html/index.html'
ruta_archivo_tottus = 'M:\WebBot\Tottus'
ruta_pix_tottus = 'mapeo_pix_tottus/'
# datos Walmart
user_wmt = 'Soc439a'
pass_wmt = 'Vodkaskyy78'
url_wmt = 'https://rllogin.wal-mart.com/rl_security/rl_logon.aspx?ServerType=IIS1&CTAuthMode=BASIC&language=en&CT_ORIG_URL=%2F&ct_orig_uri=%2F'
url_wmt_dl = 'https://retaillink.wal-mart.com'
ruta_archivo_wallmart = 'M:\WebBot\Wallmart'
now = datetime.datetime.now()
day_number = now.day
day_cod = time.gmtime().tm_wday # 0 = Lunes
print(now)
print(day_number)
print(day_cod)
def left_click(x, y):
pyautogui.click(x, y)
# recibe box=(x1, y1, x2, y2)
def screen_grab(box):
im = ImageGrab.grab(box)
#im.save(os.getcwd() + '\\img\\test' + str(now.date()) + str(box) + '.png', 'PNG')
return im
def buscadia(coordenadas, ruta, cadena='none', dia='none'):
#if day_number <= 5:
# day = 1
#else:
if day_cod == 0: # pregunta si es LUNES
day = day_number - 5 # si es lunes buscar el Viernes
else:
day = day_number - 4 # sino, busca el día anterior
print('dia buscado: ', day)
if dia == 'hoy':
day = day_number
box = ''
quitar_blanco1 = '(255, 255, 255), '
quitar_blanco2 = ', (255, 255, 255)'
quitar_azul1 = '(168, 198, 238), '
quitar_azul2 = ', (168, 198, 238)'
blanco = (255, 255, 255)
blanco1 = (250, 250, 250)
file = ruta + str(day) + '.txt'
print(file)
map = open(file, 'r')
pix_buscado = map.read()
print('-----------------------------')
print('pixel buscado: \n')
print(pix_buscado)
print('-----------------------------')
print('\n\n')
if cadena == 'none':
# Magia
if day <= 15:
for k, v in coordenadas.items():
print(k)
im = screen_grab(v)
pix = [im.getpixel((x, y)) for x in range(0, v[2] - v[0]) for y in range(0, v[3] - v[1])]
paso1 = str(pix).replace(quitar_blanco1, '')
paso2 = paso1.replace(quitar_blanco2, '')
paso3 = paso2.replace(quitar_azul1, '')
pix = paso3.replace(quitar_azul2, '')
print(pix)
if pix == pix_buscado:
box = k
print('box' + box)
break
elif day > 15:
for k, v in sorted(coordenadas.items(), key=lambda vector: int(vector[0]), reverse=True):
print(k)
im = screen_grab(v)
pix = [im.getpixel((x, y)) for x in range(0, v[2] - v[0]) for y in range(0, v[3] - v[1])]
paso1 = str(pix).replace(quitar_blanco1, '')
paso2 = paso1.replace(quitar_blanco2, '')
paso3 = paso2.replace(quitar_azul1, '')
pix = paso3.replace(quitar_azul2, '')
print(pix)
if pix == pix_buscado:
box = k
print('box' + box)
break
if cadena == 'tottus':
# Magia
if day <= 15:
for k, v in coordenadas.items():
print(k)
im = screen_grab(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)
print(pix)
if str(pix) == pix_buscado:
box = k
print('box' + box)
break
elif day > 15:
for k, v in sorted(coordenadas.items(), key=lambda vector: int(vector[0]), reverse=True):
print(k)
im = screen_grab(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)
print(pix)
if str(pix) == pix_buscado:
box = k
print('encontrado en: box' + box)
break
x = coordenadas.get(box)[0] + 3 # primera coordenada
y = coordenadas.get(box)[1] + 3 # segunda coordenada
return x, y
def smu():
#inicio
coord_x1_ini_tot = 987
coord_y1_ini_tot = 662
coord_x2_ini_tot = 1004
coord_y2_ini_tot = 675
'''
#fin
coord_x1 = 1203
coord_y1 = 662
coord_x2 = 1220
coord_y2 = 675
'''
coord_x1 = 195
coord_y1 = 556
coord_x2 = 212
coord_y2 = 569
cont = 1
calendar_coord_smu = {}
# abro IE
browser = webdriver.Ie(ie_driver)
browser.get(url_smu)
time.sleep(20)
left_click(1016, 425)
left_click(1016, 425)
time.sleep(0.25)
pyautogui.typewrite(user_smu, interval=0.2)
time.sleep(0.25)
left_click(1016, 449)
left_click(1016, 449)
time.sleep(0.25)
pyautogui.typewrite(pass_smu, interval=0.2)
time.sleep(0.25)
left_click(989, 479)
# click para sacar primer pop-up
time.sleep(20)
#left_click(1271, 447)
left_click(1553, 132)
time.sleep(5)
# click en comercial
left_click(455, 132)
time.sleep(5)
# click en informe de ventas
left_click(523, 184)
time.sleep(20)
# click para sacar segundo pop-up
left_click(1553, 132)
time.sleep(5)
if day_number > 5:
# calendario inicio
left_click(193, 507)
time.sleep(0.1)
for x in range(6): # 6 líneas de cajas
for y in range(7): # 7 cajas por línea
print(coord_x1, coord_y1, coord_x2, coord_y2)
linea = {str(cont): (coord_x1, coord_y1, coord_x2, coord_y2)}
calendar_coord_smu.update(linea)
cont += 1
if y % 2 == 0:
coord_x1 += 25
coord_x2 += 25
else:
coord_x1 += 24
coord_x2 += 24
coord_x1 = 195
coord_x2 = 212
coord_y1 += 23
coord_y2 += 23
x, y = buscadia(calendar_coord_smu, ruta_pix_smu)
time.sleep(0.5)
left_click(x, y)
time.sleep(0.5)
# generar informe
left_click(423, 619)
time.sleep(20)
# descargar informe
#left_click(1717, 279)
#time.sleep(4)
#click en descargar total (icono azul)
left_click(1751, 279)
time.sleep(20)
if day_number > 5:
cont = 1
calendar_coord_smu = {}
# calendario inicio
left_click(985, 613)
time.sleep(0.2)
for x in range(6): # 6 líneas de cajas
for y in range(7): # 7 cajas por línea
print(coord_x1_ini_tot, coord_y1_ini_tot, coord_x2_ini_tot, coord_y2_ini_tot)
linea = {str(cont): (coord_x1_ini_tot, coord_y1_ini_tot, coord_x2_ini_tot, coord_y2_ini_tot)}
calendar_coord_smu.update(linea)
cont += 1
if y % 2 == 0:
coord_x1_ini_tot += 25
coord_x2_ini_tot += 25
else:
coord_x1_ini_tot += 24
coord_x2_ini_tot += 24
coord_x1_ini_tot = 987
coord_x2_ini_tot = 1004
coord_y1_ini_tot += 23
coord_y2_ini_tot += 23
x, y = buscadia(calendar_coord_smu, ruta_pix_smu)
left_click(x, y)
time.sleep(0.5)
left_click(893, 725)
time.sleep(20)
# CSV
#left_click(883, 576)
#time.sleep(2)
# Excel
#left_click(883, 619)
#time.sleep(2)
# seleccionar
#left_click(963, 658)
#time.sleep(4)
# boton guardar
left_click(911, 655)
time.sleep(20)
# click en url del explorador de windows
left_click(646, 47)
time.sleep(0.25)
pyautogui.typewrite(ruta_archivo_smu, interval=0.2)
pyautogui.press('enter')
# click en nombre del explorador de windows
left_click(602, 438)
time.sleep(0.25)
pyautogui.typewrite('archivo_' + str(now.date()) + '.rar', interval=0.2)
time.sleep(0.25)
pyautogui.press('enter')
# guardar en pc
#left_click(513, 447)
#time.sleep(2)
# cerrar
time.sleep(20)
left_click(1012, 655)
# cerrar sesión
time.sleep(0.5)
left_click(1904, 132)
#extraigo el rar
Archive(ruta_archivo_smu + '\\archivo_' + str(now.date()) + '.rar').extractall(ruta_archivo_smu)
for file in os.listdir(ruta_archivo_smu):
if file.endswith(".csv"):
os.rename(os.path.join(ruta_archivo_smu, file), os.path.join(ruta_archivo_smu, 'datos.csv'))
'''texto = nombre_archivo + '.txt'
for file in os.listdir(ruta_archivo_smu):
if file.endswith(".csv"):
archivo = os.path.join(ruta_archivo_smu, file)
with open(archivo, 'r') as csvfile:
csvreader = csv.reader(csvfile, delimiter=' ')
with open(texto, 'w') as txtfile:
for row in csvreader:
txtfile.write(','.join(row) + '\n')
# print(','.join(row))
txtfile.close()
'''
def cenco():
coord_x1 = 242
coord_y1 = 532
coord_x2 = 259
coord_y2 = 545
cont = 1
calendar_coord_cenco = {}
browser = webdriver.Ie(ie_driver)
browser.get(url_cenco)
#opciones = browser.find_element_by_name('pais').send_keys('chile')
time.sleep(5)
# seleccione país
left_click(1048, 406)
time.sleep(0.25)
# seleccione CHILE
left_click(892, 436)
time.sleep(0.25)
# seleccione UN
left_click(1048, 467)
time.sleep(0.25)
# seleccione Supermercados
left_click(953, 528)
time.sleep(0.25)
# Ingresar
left_click(961, 511)
time.sleep(3)
# Login User
left_click(1037, 423)
time.sleep(0.25)
pyautogui.typewrite(user_cenco, interval=0.2)
#pyautogui.press('enter')
time.sleep(0.25)
# Login Paswword
left_click(1037, 463)
time.sleep(0.25)
pyautogui.typewrite(pass_cenco, interval=0.2)
pyautogui.press('enter')
time.sleep(12)
# quita pop-pu
#left_click(1069, 283)
time.sleep(0.25)
# Click en Comercial
left_click(424, 123)
time.sleep(0.25)
# Click en ventas
left_click(445, 153)
time.sleep(10)
if day_number > 5:
# Click en Calendario
left_click(240, 482)
time.sleep(0.5)
# coordenadas de cajas
for x in range(6): # 6 líneas de cajas
for y in range(7): # 7 cajas por línea
print(coord_x1, coord_y1, coord_x2, coord_y2)
linea = {str(cont): (coord_x1, coord_y1, coord_x2, coord_y2)}
calendar_coord_cenco.update(linea)
cont += 1
if y % 2 == 0:
coord_x1 += 25
coord_x2 += 25
else:
coord_x1 += 24
coord_x2 += 24
coord_x1 = 242
coord_x2 = 259
coord_y1 += 23
coord_y2 += 23
x, y = buscadia(calendar_coord_cenco, ruta_pix_cenco)
left_click(x, y)
time.sleep(2)
# generar informe
left_click(426, 582)
time.sleep(15)
# descargar informe
#left_click(1819, 294)
#time.sleep(3)
left_click(1887, 251)
time.sleep(4)
left_click(893, 689)
time.sleep(60)
# CSV
# left_click(883, 576)
# time.sleep(2)
# Excel
# left_click(883, 619)
# time.sleep(2)
# seleccionar
#left_click(962, 658)
#time.sleep(5)
# boton guardar
left_click(911, 654)
time.sleep(5)
# click en url del explorador de windows
left_click(646, 47)
time.sleep(0.25)
pyautogui.typewrite(ruta_archivo_cenco, interval=0.2)
pyautogui.press('enter')
# click en nombre del explorador de windows
left_click(602, 438)
pyautogui.typewrite('archivo_' + str(now.date()) + '.rar', interval=0.2)
time.sleep(0.1)
pyautogui.press('enter')
# guardar en pc
# left_click(513, 447)
# time.sleep(2)
# cerrar
time.sleep(5)
left_click(1012, 654)
# cerrar sesión
time.sleep(1)
left_click(1888, 124)
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'))
def tottus():
'''
coord_ini_x1 = 476
coord_ini_y1 = 348
coord_ini_x2 = 493
coord_ini_y2 = 358
cont_ini = 1
calendar_coord_tottus_inicio = {}
coord_fin_x1 = 1059
coord_fin_y1 = 348
coord_fin_x2 = 1076
coord_fin_y2 = 358
cont_fin = 1
calendar_coord_tottus_fin = {}
'''
browser = webdriver.Ie(ie_driver)
browser.get(url_tottus)
time.sleep(5)
# dropdown
left_click(1210, 255)
time.sleep(0.25)
left_click(1210, 242)
time.sleep(0.25)
left_click(1024, 602)
time.sleep(0.25)
left_click(1210, 255)
time.sleep(0.25)
left_click(1210, 269)
time.sleep(0.25)
# Rut Empresa
pyautogui.doubleClick(1236, 275)
time.sleep(0.25)
pyautogui.typewrite(rut_empresa, interval=0.2)
# Uusario Tottus
pyautogui.doubleClick(1236, 308)
time.sleep(0.25)
pyautogui.typewrite(user_tottus, interval=0.2)
# Password Tottus
pyautogui.doubleClick(1236, 340)
time.sleep(0.25)
pyautogui.typewrite(pass_tottus, interval=0.2)
# Ingresar
left_click(1204, 385)
time.sleep(5)
# Ventas
pyautogui.moveTo(201, 149, duration=0.5)
pyautogui.mouseDown()
pyautogui.moveTo(209, 149, duration=0.5)
pyautogui.moveTo(209, 248, duration=0.5)
left_click(209, 248)
pyautogui.mouseUp()
time.sleep(10)
if day_cod == 0: # pregunta si es LUNES
fecha = datetime.datetime.today() - datetime.timedelta(days=4) # si es lunes buscar el Viernes
else:
fecha = datetime.datetime.today() - datetime.timedelta(days=2) # sino, busca el día anterior
hoy = datetime.datetime.today() - datetime.timedelta(days=1)
time.sleep(1)
# Click en Calendario_inicio
left_click(605, 288)
time.sleep(0.5)
pyautogui.typewrite(str(hoy.strftime("%d/%m/%Y")), interval=0.2)
#pyautogui.typewrite(str(fecha.strftime("%d/%m/%Y")), interval=0.2)
left_click(1427, 289)
time.sleep(0.5)
#hoy = datetime.datetime.today()
pyautogui.typewrite(str(hoy.strftime("%d/%m/%Y")), interval=0.2)
# check box
left_click(561, 309)
time.sleep(0.25)
# generar informe
left_click(964, 338)
time.sleep(10)
# descargar informe
left_click(1265, 1018)
time.sleep(10)
#mueve el archivo
shutil.move('C:/Users/smunoz/Downloads/datos.csv', os.path.join(ruta_archivo_tottus, 'datos.csv'))
# cerrar
time.sleep(0.25)
left_click(1397, 111)
def wallmart():
browser = webdriver.Chrome(chrome_driver)
browser.get(url_wmt)
# mi usuario y doy next
username = browser.find_element_by_id('txtUser')
username.send_keys(user_wmt)
password = browser.find_element_by_id('txtPass')
password.send_keys(pass_wmt)
nextButton = browser.find_element_by_id('Login')
nextButton.click()
containers = browser.find_elements_by_xpath('//i[@class="icon-download-alt mediumBlueIcon downloadIcon"]')
print('print containers:\n\n ')
print(containers)
print('\n\n')
url = ''
for item in containers:
print(item.get_attribute('id'))
if 'Sell Out Walmart VSR (Bot Planeamiento-No Borrar)' in item.get_attribute('id'):
url = url_wmt_dl + item.get_attribute('id')
print('URL NORMAL')
print('url: ' + url)
break
if 'Sell Out Walmart VSR (Bot Planeamiento-No Borrar) intento 2' in item.get_attribute('id'):
url = url_wmt_dl + item.get_attribute('id')
print('URL BACKUP 2')
print('url: ' + url)
break
if 'Sell Out Walmart VSR (Bot Planeamiento-No Borrar) intento 3' in item.get_attribute('id'):
url = url_wmt_dl + item.get_attribute('id')
print('URL BACKUP 3')
print('url: ' + url)
break
if 'Sell Out Walmart VSR (Bot Planeamiento-No Borrar) intento 4' in item.get_attribute('id'):
url = url_wmt_dl + item.get_attribute('id')
print('URL BACKUP 4')
print('url: ' + url)
break
if 'Sell Out Walmart VSR (Bot Planeamiento-No Borrar) intento 5' in item.get_attribute('id'):
url = url_wmt_dl + item.get_attribute('id')
print('URL BACKUP 5')
print('url: ' + url)
break
browser.get(url)
time.sleep(240)
#pyautogui.hotkey('ctrl', 's')
for file in os.listdir(ruta_descarga):
if file.endswith(".txt"):
os.rename(os.path.join(ruta_descarga, file), os.path.join(ruta_descarga, 'datos.txt'))
# mueve el archivo
shutil.move(ruta_descarga + '\datos.txt', os.path.join(ruta_archivo_wallmart, 'datos.txt'))
'''
# click en url del explorador de windows
left_click(646, 47)
time.sleep(0.25)
pyautogui.typewrite(ruta_archivo_wallmart, interval=0.2)
pyautogui.press('enter')
time.sleep(0.25)
# click en nombre del explorador de windows
left_click(602, 438)
# pyautogui.typewrite('archivo_' + str(now.date()) + '.txt', interval=0.2)
pyautogui.typewrite('datos.txt', interval=0.2)
time.sleep(0.1)
pyautogui.press('enter')
'''
def elimina_archivos():
try:
os.remove(path=ruta_archivo_wallmart + '\datos.txt')
except Exception as e:
print(e)
#cursor = conn.cursor()
#currenttime = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S")
#cursor.execute("insert into B2B..ErrorLog_Bot_B2B values (?, 'test')", currenttime)
#cursor.execute("insert into B2B..ErrorLog_Bot_B2B values ('" + str(now) + "','" + str('hola') + "')")
#cursor.close()
pass
try:
os.remove(path=ruta_archivo_smu + '\datos.csv')
except Exception as e:
print(e)
pass
try:
os.remove(path=ruta_archivo_smu + '\\archivo_' + str(now.date()) + '.rar')
except Exception as e:
print(e)
pass
try:
os.remove(path=ruta_archivo_cenco + '\datos.csv')
except Exception as e:
print(e)
pass
try:
os.remove(path=ruta_archivo_cenco + '\\archivo_' + str(now.date()) + '.rar')
except Exception as e:
print(e)
pass
try:
os.remove(path=ruta_archivo_tottus + '\datos.csv')
except Exception as e:
print(e)
pass
def job():
print('corriendo Wallmart:')
try:
wallmart()
print('OK')
except Exception as e:
time.sleep(2)
print('Falló')
print(e)
pass
print('corriendo SMU:')
try:
smu()
print('OK')
except Exception as e:
time.sleep(2)
print('Falló')
print(e)
pass
print('corriendo Cenco:')
try:
cenco()
print('OK')
except Exception as e:
time.sleep(2)
print('Falló')
print(e)
pass
print('corriendo Tottus:')
try:
tottus()
print('OK')
except Exception as e:
time.sleep(2)
print('Falló')
print(e)
pass
def job2():
print('Eliminando archivos:')
try:
elimina_archivos()
print('OK')
except Exception as e:
time.sleep(2)
print('Falló')
print(e)
pass
def main():
'''
# pasar a TXT
import csv
csv_file = raw_input('Enter the name of your input file: ')
txt_file = raw_input('Enter the name of your output file: ')
with open(txt_file, "w") as my_output_file:
with open(csv_file, "r") as my_input_file:
[my_output_file.write(" ".join(row) + '\n') for row in csv.reader(my_input_file)]
my_output_file.close()
# scheduler
https://github.com/dbader/schedule/blob/master/test_schedule.py
import schedule
import time
schedule.every(1).minutes.do(job)
schedule.every().hour.do(job)
def job(t):
print "I'm working...", t
return
'''
schedule.every().day.at("05:00").do(job2)
schedule.every().day.at("13:54").do(job)
while True:
schedule.run_pending()
print(datetime.datetime.now())
time.sleep(2) # wait x = 1 sec
if __name__ == '__main__':
main()