From 1aa266728c93ead41787bc31b05ce1f604c01196 Mon Sep 17 00:00:00 2001 From: Junicchi <24779257+KebabLord@users.noreply.github.com> Date: Sun, 7 Feb 2021 23:58:39 +0300 Subject: [PATCH] =?UTF-8?q?Hata=204088=20(no=20moz:firefoxOptions.binary?= =?UTF-8?q?=20provided)=20kabaca=20=C3=A7=C3=B6z=C3=BCld=C3=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- turkanime_api/tools.py | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/turkanime_api/tools.py b/turkanime_api/tools.py index bc957b2..ab2a54c 100644 --- a/turkanime_api/tools.py +++ b/turkanime_api/tools.py @@ -2,8 +2,10 @@ import subprocess as sp from os import name from prompt_toolkit import styles +from configparser import ConfigParser from selenium import webdriver from selenium.webdriver.firefox.options import Options +from selenium.common.exceptions import SessionNotCreatedException def gereksinim_kontrol(): """ Gereksinimlerin erişilebilir olup olmadığını kontrol eder """ @@ -24,8 +26,12 @@ def gereksinim_kontrol(): def webdriver_hazirla(): """ Selenium webdriver'ı hazırla """ + parser = ConfigParser() + parser.read("./config.ini") options = Options() options.add_argument('--headless') + if parser.has_option("TurkAnime","firefox konumu"): + options.binary_location = parser.get("TurkAnime","firefox konumu") profile = webdriver.FirefoxProfile() profile.set_preference("dom.webdriver.enabled", False) profile.set_preference('useAutomationExtension', False) @@ -34,14 +40,27 @@ def webdriver_hazirla(): profile.update_preferences() desired = webdriver.DesiredCapabilities.FIREFOX if name == 'nt': - return webdriver.Firefox( - profile, options=options,service_log_path='NUL', - executable_path=r'geckodriver.exe', desired_capabilities=desired - ) + try: + return webdriver.Firefox( + profile, options=options,service_log_path='NUL', + executable_path=r'geckodriver.exe', desired_capabilities=desired + ) + except SessionNotCreatedException: + input("Program Firefox'un kurulu olduğu dizini tespit edemedi "+ + "Manuel olarak girmek için yönlendirileceksiniz.\n"+ + "(Devam etmek için entera basın)") + from easygui import fileopenbox + indirilenler_dizin=fileopenbox("/") + if indirilenler_dizin: + parser.set("TurkAnime","firefox konumu",indirilenler_dizin) + with open("./config.ini","w") as f: + parser.write(f) + input("Programı yeniden başlatmalısınız. (Devam etmek için entera basın)") + kapat() return webdriver.Firefox( profile, options=options, service_log_path='/dev/null',desired_capabilities=desired - ) + ) prompt_tema = styles.Style([ ('qmark', 'fg:#5F819D bold'),