-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpwanewchoice.py
216 lines (188 loc) · 7.37 KB
/
pwanewchoice.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
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
from pywinauto.application import Application
import sys
import re
import platform
from time import sleep
from colorama import init, Fore, Back, Style
import pandas as pd
from tinydb import TinyDB, Query
db = TinyDB('checker.json')
init()
print ( Back.BLUE+Fore.YELLOW+Style.BRIGHT+"\n\nKIU Checker - CHOICE TO KIU Script Prototipo por Efrain Valles\n\n\
Se inicio KIU, Ingrese sus datos de inicio en KIU en \n\n\
Para iniciar precione esta ventana (s) \n"+Style.RESET_ALL)
windows=platform.platform()
#Iniciando KIU
try:
if windows.startswith("Windows-7"):
app = Application().connect(title_re=".*KIU*", class_name="TApplication")
dlg = app.TApplication
elif windows.startswith("Windows-10"):
app = Application().connect(title_re=".*KIU*", class_name="KIU")
print("Es Windows-10")
dlg = app.KIU
except:
app = Application().start("C:\Reservas\clienteres.exe")
if windows.startswith("Windows-7"):
dlg = app.TApplication
elif windows.startswith("Windows-10"):
print("Es Windows-10")
dlg = app.KIU
try:
if windows.startswith("Windows-7"):
app2 = Application().connect(title_re=".*python*", class_name="ConsoleWindowClass")
elif windows.startswith("Windows-10"):
app2 = Application().connect(title_re="Command Prompt - python*", class_name="ConsoleWindowClass")
except:
print("Error en Capturar")
dlg.window()
dlg.move_window(x=600, y=0, width=600, height=400, repaint=True)
dlg2 = app2.ConsoleWindowClass
dlg2.move_window(x=600, y=0, width=600, height=400, repaint=True)
filePath = str(sys.argv[1])
list_apis=[]
list_checked=[]
print("El archivo es %s" % filePath)
try:
df = pd.read_csv(filePath)
except UnicodeDecodeError:
# df = pd.read_csv(filePath,encoding = "ISO-8859-1")
df = pd.read_csv(filePath,engine='python')
pass
vuelo = df['Unnamed: 7'][1][:3]
fechavuelo = df['Unnamed: 7'][3][:11]
dep_airp = df['Unnamed: 7'][2][:3]
dest_airp = df['Unnamed: 13'][2][:3]
df.drop(df.head(5).index,inplace=True)
df.drop(df.tail(2).index,inplace=True)
clsdf=df.drop(['Unnamed: 1','Unnamed: 3','Unnamed: 5','Unnamed: 7','Passenger Manifest','Unnamed: 13','Unnamed: 16','Unnamed: 17','Unnamed: 18'], axis=1)
clsdf=clsdf.rename(columns={'Unnamed: 0':'chk order','Unnamed: 2': 'pnr','Unnamed: 4': 'last','Unnamed: 6': 'first','Unnamed: 9': 'middle','Unnamed: 10': 'dob','Unnamed: 11': 'gen','Unnamed: 12': 'dest','Unnamed: 14': 'seat','Unnamed: 15':'bags',})
clsdf.reset_index(drop=True,inplace=True)
print(clsdf)
vueloinfo= "Vuelo: AG %s - %s %s %s" % (vuelo,fechavuelo,dep_airp,dest_airp)
print("para el vuelo %s" % (vueloinfo))
breaklist=""
#check if it is in the database
FLTQ=Query()
if db.search(FLTQ.archivo==filePath):
print("The File is in")
resultdb = db.search(FLTQ.archivo == filePath)
print(resultdb)
breaklist= resultdb[0].get("last_checkin")
else:
db.insert({'archivo': filePath,'last_checkin':'0'})
def searchpax(rowitem,orden):
print ("Orden llego asi" + orden)
try:
if orden == "R":
dlg.type_keys("PF-%s{ENTER}" % (rowitem['last'][:5]))
if orden =="":
dlg.type_keys("PF-%s{ENTER}" % (rowitem['last'].replace(" ","{VK_SPACE}")))
except:
print("Error", sys.exc_info())
pass
sleep(1)
print(Style.BRIGHT)
print("Nombre Completo:")
print(Back.BLUE+Fore.YELLOW+"%s/%s" % (rowitem['last'],rowitem['first']))
print(Style.RESET_ALL)
print(Style.BRIGHT)
dlg2.set_focus()
ordenit = input("\nIngrese el orden ([#],[s](saltar pax), [c] si ya estaba chequeado [r] para repetir con menos letras:")
ordenit=ordenit.upper()
return (ordenit)
def checkit(listofpax):
list_pending=pd.DataFrame(columns = ['chk order' , 'pnr', 'last' , 'first','middle' , 'dob','gen', 'dest' , 'seat', 'bags'])
for index, row in listofpax.iterrows():
orden=""
print (row)
db.update({'last_checkin': index}, FLTQ.archivo == filePath)
#indi= listofpax.index(i)
#if i[0] == "**INF**":
# print("pax es infante, chequee manual \n %s" % (i))
# continue
sleep(1)
while orden == "R" or orden == "":
print("orden es" + orden)
orden=orden.upper()
orden = searchpax(row,orden)
print ("La orden al final loop es " + orden)
print("orden es AQUI CHIQUI " + orden)
if orden == "S":
print("*** SALTANDO PASAJERO ***")
sleep(1)
data = {'chk order': row['chk order'],
'pnr': row['pnr'],
'last': row['last'],
'first': row['first'],
'middle': row['middle'],
'dob': row['dob'],
'gen': row['gen'],
'dest': row['dest'],
'seat': row['seat'],
'bags': row['bags']}
list_pending = list_pending.append(data, ignore_index=True)
print (list_pending)
print (len(list_pending))
dlg2.set_focus()
continue
if orden == "C":
print(Back.WHITE+Fore.RED+Style.BRIGHT+"*** pax ya estaba chequeado ***"+Style.RESET_ALL)
list_checked.append(row)
dlg2.set_focus()
if orden =="R":
print(Back.BLUE+Fore.WHITE+Style.BRIGHT+"*** buscando con menos caracteres ***"+Style.RESET_ALL)
searchpax(row,orden)
if orden == "NO":
break
continue
if row['bags'] is not "0" and orden[0].isdigit():
try:
dlg.type_keys("PU%s%s,ST%s{ENTER}" % (orden,row['gen'],row['seat']))
except:
print('error')
pass
sleep(1)
list_checked.append(row)
try:
dlg2.set_focus()
except:
print("error")
pass
elif row['bags'] is "0" and orden[0].isdigit():
dlg.type_keys("PU%s%s,ST%s{ENTER}" % (orden,row['gen'],row['seat']))
list_checked.append(row, ignore_index(True))
sleep(1)
try:
dlg2.set_focus()
except:
print("error")
pass
return list_pending
inicio = input("desea iniciar? (s/n) :")
if inicio == "s":
print("Iniciando checkin backoffice - %s" % (vueloinfo))
else:
sys.exit()
sleep(1)
if breaklist is "":
breaklist = input("desea iniciar desde un orden especifico #? :")
print (len(list_apis))
if breaklist is not "":
print ("Esta es %d" % (int(breaklist)))
#del list_apis[0:int(breaklist)]
clsdf.drop(clsdf.index[0:(int(breaklist))],inplace=True)
print(clsdf)
else:
print("iniciando desde el principio")
print("\n\n Ingrese el Header del Vuelo en KIU y presione s para iniciar")
iniciar = input("iniciar (s/n): ")
if iniciar == "s":
listofpaxtocheck = checkit(clsdf)
while len(listofpaxtocheck) > 0:
print("Estos son los pasajeros pendientes")
for index, row in listofpaxtocheck.iterrows():
print(row)
chequear=input("desea chequearlos?")
if chequear == "s" or chequear == "S":
listofpaxtocheck=checkit(listofpaxtocheck)