Exception handling for date

main
Bob Mottram 2021-09-15 18:43:06 +01:00
parent b715146a85
commit 97d6724e0d
1 changed files with 7 additions and 2 deletions

View File

@ -526,6 +526,7 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
"""Converts rss items in a newswire into posts
"""
if not newswire:
print('No newswire to convert')
return
basePath = baseDir + '/accounts/news@' + domain + '/outbox'
@ -542,8 +543,12 @@ def _convertRSStoActivityPub(baseDir: str, httpPrefix: str,
dateStr = dateStr.replace(' ', 'T')
dateStr = dateStr.replace('+00:00', 'Z')
else:
try:
dateStrWithOffset = \
datetime.datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
except BaseException:
print('Newswire strptime failed ' + str(dateStr))
continue
dateStr = dateStrWithOffset.strftime("%Y-%m-%dT%H:%M:%SZ")
statusNumber, published = getStatusNumber(dateStr)