forked from birolemekli/tcdd-bilet-yer-kontrol
-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
101 lines (70 loc) · 2.58 KB
/
main.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
# -*- coding: utf-8 -*-
"""
@author: Birol Emekli
"""
from selenium import webdriver
from time import sleep
import sys
from urllib.parse import urlencode
from urllib.request import Request, urlopen
import PySimpleGUI as sg
from threading import Thread
import Control, Rota, DriverSetting , DriverGet
class PushSafer():
def sendNotification(self, baslik, mesaj):
url = 'https://www.pushsafer.com/api'
post_fields = {
"t" : baslik,
"m" : mesaj,
"s" : 20,
"pr": 2,
"v" : 3,
"i" : 9,
"d" : 'a',
"k" : "key"
}
request = Request(url, urlencode(post_fields).encode())
json = urlopen(request).read().decode()
print(json)
pushSafer = PushSafer()
def driverSetting():
return DriverSetting.DriverSetting().driverUP()
def driverGet(drivers):
DriverGet.DriverGet(drivers).driverGet()
def rota(driver,first_location,last_location,date):
Rota.Rota(driver, first_location, last_location, date).dataInput()
def control(driver,timee):
response = Control.Control(driver,timee).sayfaKontrol()
if response == "successful":
pushSafer.sendNotification('TCDD Bilet Kontrol', "2'den fazla bilet bulundu")
driver.quit()
sys.exit()
font = ('Arial', 10)
sg.theme('DarkBlue')
layout = [
[[sg.Column([[sg.Text('TCDD')]], justification='center')]],
[sg.Text('Nereden :',size=(7,1)), sg.Combo(['Gebze','Bilecik YHT'],default_value='Gebze',key='nereden')],
[sg.Text('Nereye :',size=(7,1)), sg.Combo(['Gebze','Bilecik YHT'],default_value='Bilecik YHT',key='nereye')],
[sg.Text('Tarih :',size=(7,1)), sg.InputText(['18.07.2022'],size=(14,5),key='tarih')],
[sg.Text('Saat :',size=(7,1)), sg.InputText(['09:11'],size=(14,5),key='saat')],
[sg.Button('Ara'), sg.Button('Durdur'),sg.Button('Kapat')]
]
window = sg.Window('Python App',layout,size = (250, 250),resizable = False,font=font)
def mainLoop():
while True:
driver = driverSetting()
driverGet(driver)
rota(driver,nereden,nereye,tarih)
control(driver,saat)
sleep(30)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Kapat':
window.close()
sys.exit()
if event == 'Ara':
nereden = values['nereden']
nereye = values['nereye']
tarih = '18.07.2022'
saat = '09:11'
th = Thread(target=mainLoop).start()