Commit 3d187407 authored by Jerome Berthier's avatar Jerome Berthier Committed by Vincent A

weboob.exceptions: add some helpers to TooManyRequests

Usually the next_try will be the next day or the next 24h, so
to avoid modules to compute it everytime we do it here.
parent 04a9d386
......@@ -47,9 +47,19 @@ class BrowserTooManyRequests(BrowserUnavailable):
Client tries to perform too many requests within a certain timeframe.
The module should set the next_try if possible, else it is set to 24h.
"""
# next day at 00h00
NEXT_DAY = datetime.date.today() + relativedelta(days=1)
# in exactly 24h
NEXT_24H = datetime.datetime.now() + relativedelta(days=1)
def __init__(self, next_try=None):
if next_try is None:
next_try = datetime.datetime.now() + relativedelta(days=1)
next_try = BrowserTooManyRequests.NEXT_24H
if isinstance(next_try, datetime.date):
next_try = datetime.datetime.combine(next_try, datetime.datetime.min.time())
self.next_try = next_try
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment