Skip to content
Open
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
21 changes: 20 additions & 1 deletion stores/amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,24 @@ def login(self):
# Wait for the user to enter 2FA
time.sleep(2)
log.info(f'Logged in as {amazon_config["username"]}')


@debug
def relogin(self):
while True:
try:
self.get_page(url=AMAZON_URLS["BASE_URL"])
break
except sel_exceptions.WebDriverException:
log.error(
"Couldn't talk to "
+ AMAZON_URLS["BASE_URL"]
+ ", if the address is right, there might be a network outage..."
)
time.sleep(3)
pass
self.handle_startup()
self.login()

@debug
def run_asins(self, delay):
found_asin = False
Expand Down Expand Up @@ -649,6 +666,8 @@ def check_stock(self, asin, reserve_min, reserve_max, retry=0):
return False
if len(offer_count) == 0:
log.info("No offers found. Moving on.")
if not self.is_logged_in():
self.relogin()
return False
log.info(
f"Found {len(offer_count)} offers for {asin}. Evaluating offers..."
Expand Down