fix time formatting for Python 3.4 and 3.5
'datetime.time.isoformat()' only has an optional 'timespec' argument since Python 3.6.
This commit is contained in:
@@ -135,7 +135,8 @@ class Extractor():
|
||||
raise ValueError("Either 'seconds' or 'until' is required")
|
||||
|
||||
if reason:
|
||||
isotime = until.time().isoformat("seconds")
|
||||
t = until.time()
|
||||
isotime = "{:02}:{:02}:{:02}".format(t.hour, t.minute, t.second)
|
||||
self.log.info("Waiting until %s for %s.", isotime, reason)
|
||||
time.sleep(seconds + adjust)
|
||||
|
||||
|
||||
@@ -407,11 +407,12 @@ class TumblrAPI(oauth.OAuth1API):
|
||||
# daily rate limit
|
||||
if response.headers.get("x-ratelimit-perday-remaining") == "0":
|
||||
reset = response.headers.get("x-ratelimit-perday-reset")
|
||||
until = datetime.now() + timedelta(seconds=float(reset))
|
||||
t = (datetime.now() + timedelta(seconds=float(reset))).time()
|
||||
|
||||
self.log.error("Daily API rate limit exceeded")
|
||||
raise exception.StopExtraction(
|
||||
"Aborting - Rate limit will reset at %s",
|
||||
until.time().isoformat("seconds"))
|
||||
"{:02}:{:02}:{:02}".format(t.hour, t.minute, t.second))
|
||||
|
||||
# hourly rate limit
|
||||
reset = response.headers.get("x-ratelimit-perhour-reset")
|
||||
|
||||
Reference in New Issue
Block a user