Time data does not match format '%Y-%m-%dT%H:%M:%S.%fZ'

Bug: #1659807
Change-Id: Iec6bf294562d9df8d2db7dbd212b7d35e91ad43a
Sem-Ver: bugfix
This commit is contained in:
Lisa Zangrando 2017-01-27 13:46:41 +01:00
parent 80ef20c334
commit e107158e9b
1 changed files with 18 additions and 4 deletions

View File

@ -45,11 +45,25 @@ class Token(SynergyObject):
token.setId(id)
data = data["token"]
token.setCreation(datetime.strptime(data["issued_at"],
"%Y-%m-%dT%H:%M:%S.%fZ"))
issued_at = None
expires_at = None
token.setExpiration(datetime.strptime(data["expires_at"],
"%Y-%m-%dT%H:%M:%S.%fZ"))
try:
issued_at = datetime.strptime(data["issued_at"],
"%Y-%m-%dT%H:%M:%S.%fZ")
except Exception:
issued_at = datetime.strptime(data["issued_at"],
"%Y-%m-%dT%H:%M:%S.%f")
try:
expires_at = datetime.strptime(data["expires_at"],
"%Y-%m-%dT%H:%M:%S.%fZ")
except Exception:
expires_at = datetime.strptime(data["expires_at"],
"%Y-%m-%dT%H:%M:%S.%f")
token.setCreation(issued_at)
token.setExpiration(expires_at)
project = Project()
project.setId(data["project"]["id"])