Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small ChromeDriver fix #66

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions discogs_alert/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
import requests
from fake_useragent import UserAgent
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromiumService
from selenium.webdriver.chromium.options import ChromiumOptions
from selenium.webdriver.chromium.service import ChromiumService
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.core.os_manager import ChromeType

from discogs_alert import entities as da_entities, scrape as da_scrape

Expand Down Expand Up @@ -131,10 +130,10 @@ def get_driver_path(self):
try:
# to install both chromium binary and the matching chromedriver binary:
# apt-get install chromium-driver
return subprocess.check_output(['which', 'chromedriver']).decode().strip()
return subprocess.check_output(["which", "chromedriver"]).decode().strip()
except subprocess.CalledProcessError:
# will install latest chromedriver binary regardless of currently installed chromium version
return ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()
return ChromeDriverManager().install()

def get_marketplace_listings(self, release_id: int) -> da_entities.Listings:
"""Get list of listings currently for sale for particular release (by release's discogs ID)"""
Expand Down
6 changes: 4 additions & 2 deletions discogs_alert/loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def loop(
if verbose:
logger.info("\nrunning loop")

client_anon = None
try:
client_anon = da_client.AnonClient(user_agent)
user_token_client = da_client.UserTokenClient(user_agent, discogs_token)
Expand Down Expand Up @@ -132,5 +133,6 @@ def loop(
logger.info(f"\t took {time.time() - start_time}")

# clean up Chrome clients
client_anon.driver.close()
client_anon.driver.quit()
if client_anon is not None:
client_anon.driver.close()
client_anon.driver.quit()
Loading