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:
Mike Fährmann
2020-01-05 00:47:10 +01:00
parent 43ab9572b4
commit 3811fd8a25
2 changed files with 5 additions and 3 deletions

View File

@@ -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)

View File

@@ -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")