Browse Source

Revert "PR865 [aws] change exception error to AssertionError and modify regex (#865)"

This reverts commit 26eee97bdb7b94e714f9e5719e6ad6d415ea9ee2.
Romain 6 years ago
parent
commit
016112c924
1 changed files with 3 additions and 3 deletions
  1. 3 3
      desktop/libs/aws/src/aws/s3/__init__.py

+ 3 - 3
desktop/libs/aws/src/aws/s3/__init__.py

@@ -131,9 +131,9 @@ def s3datetime_to_timestamp(datetime):
   # `'z' is a bad directive in format ...` error (see https://bugs.python.org/issue6641),
   # but S3 always returns time in GMT, so `GMT` and `.000Z` can be pruned.
   try:
-    assert datetime[-4:] == ' GMT', 'Time [%s] is not in GMT.' % datetime
     stripped = time.strptime(datetime[:-4], '%a, %d %b %Y %H:%M:%S')
-  except AssertionError:
-    assert datetime[-5:] == re.findall('(?i)\.\d{3}Z$', datetime)[0], 'Time [%s] is not in GMT.' % datetime
+    assert datetime[-4:] == ' GMT', 'Time [%s] is not in GMT.' % datetime
+  except ValueError:
     stripped = time.strptime(datetime[:-5], '%Y-%m-%dT%H:%M:%S')
+    assert datetime[-5:] == '.000Z', 'Time [%s] is not in GMT.' % datetime
   return int(calendar.timegm(stripped))