Skip to content

Commit

Permalink
Driver close feature add
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehmet Aksoy committed Jun 28, 2024
1 parent 1281507 commit 0f45cda
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 10 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,18 @@ TCDD bilet yer kontrol programi sayesinde tcdd sitesine surekli girmek zorunda k

## Indir

[![Download - v2.2.1](https://img.shields.io/static/v1?label=Download&message=v2.2.1&color=2ea44f)](https://github.com/mcagriaksoy/tcdd-bilet-yer-kontrol/releases/download/v2.2.1/TCDD.Bilet.Bulma.Botu.v2.2.1.zip)
[![Download - v2.3](https://img.shields.io/static/v1?label=Download&message=v2.2.1&color=2ea44f)](https://github.com/mcagriaksoy/tcdd-bilet-yer-kontrol/releases/download/v2.2.1/TCDD.Bilet.Bulma.Botu.v2.2.1.zip)

## Versionlar
v2.3
Bir Edge webdriver sorunu cozuldu.
Webdriver artik sayfanin yuklenmesini daha cok bekliyor.
Koltuk sayisini bulan regex algoritmasi yeniden yazildi.
UI tarafi:
- Artik kullanici saati 17,30 17.30 veya 17:30 cinsinde girebiliyor.
- Ayni sekilde tarihler -, ., / cinsinden de yazilabiliyor.
- Hata durumlari icin mekanizma eklendi.

v2.2.1
Chrome kaldirildi. Artik Edge ile tarama yapiliyor.
Seleniumdan kaynaklanan bir hata sebebiyle .exe surumu bozuldu. Gecici sureyle GUI arkasinda konsol cikacak.
Expand Down
12 changes: 10 additions & 2 deletions src/DriverSetting.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,17 @@

class DriverSetting:
"""Driver'ı ayarlar."""
driver = None

def driver_init(self):
options = EdgeOptions()
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = Edge(service=EdgeService(EdgeChromiumDriverManager().install()), options=options)
return driver
options.add_experimental_option("detach", True)
self.driver = Edge(service=EdgeService(EdgeChromiumDriverManager().install()), options=options)
return self.driver

def driver_quit(self):
self.driver.quit()
self.driver = None
return self.driver

Binary file removed src/__pycache__/Control.cpython-311.pyc
Binary file not shown.
Binary file removed src/__pycache__/DriverGet.cpython-311.pyc
Binary file not shown.
Binary file removed src/__pycache__/DriverSetting.cpython-311.pyc
Binary file not shown.
Binary file removed src/__pycache__/Rota.cpython-311.pyc
Binary file not shown.
Binary file removed src/__pycache__/Sehirler.cpython-311.pyc
Binary file not shown.
Binary file removed src/__pycache__/error_codes.cpython-311.pyc
Binary file not shown.
Binary file removed src/__pycache__/ui.cpython-311.pyc
Binary file not shown.
44 changes: 44 additions & 0 deletions src/main.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# -*- mode: python ; coding: utf-8 -*-


block_cipher = None


a = Analysis(
['main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='main',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
Binary file removed src/sound/beep.mp3
Binary file not shown.
Binary file removed src/sound/notification.mp3
Binary file not shown.
17 changes: 10 additions & 7 deletions src/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import error_codes as ErrCodes
import PySimpleGUI as sg

g_isStopped = False

def main():
def driver_setting():
Expand All @@ -35,18 +36,18 @@ def driver_get(drivers):
def route(driver, first_location, last_location, date):
""" Rota bilgilerini alır ve gerekli yerlere yazar.""" ""
isError = Rota.Rota(driver, first_location, last_location, date).dataInput()
if isError == -1:
if isError == -1 or g_isStopped == True:
window["Aramaya Başla"].update(disabled=False)
window["Durdur!"].update(disabled=True)
driver.quit()
exit()

def kill_chrome():
"""Chrome'u kapatır."""
if platform == "win32":
system("taskkill /im chrome.exe /f")
if platform.system() == "Windows":
system("taskkill /im chromium.exe /f")
else:
system("pkill chrome")
system("pkill chromium")

def control(driver, time, delay_time, telegram_msg, bot_token, chat_id, ses):
"""Sayfada yer var mı yok mu kontrol eder."""
Expand Down Expand Up @@ -174,6 +175,9 @@ def control(driver, time, delay_time, telegram_msg, bot_token, chat_id, ses):

def thread1(delay_time, telegram_msg, bot_token, chat_id, ses):
"""Arama dongusu!"""
global g_isStopped
g_isStopped = False

while True:
""" Arama dongusu!"""
driver = driver_setting()
Expand All @@ -185,9 +189,6 @@ def thread1(delay_time, telegram_msg, bot_token, chat_id, ses):
def thread2():
"""Durdurma dongusu!"""
window["log"].update(value="")
# Control.Control(data, None).kill_driver()
kill_chrome()
print("Web Surucusu Kapandi!")

while True:
event, values = window.read()
Expand All @@ -200,6 +201,8 @@ def thread2():
if event == "Durdur!":
window["Aramaya Başla"].update(disabled=False)
window["Durdur!"].update(disabled=True)
global g_isStopped
g_isStopped = True
t2 = Thread(target=thread2)
t2.start()

Expand Down

0 comments on commit 0f45cda

Please sign in to comment.