mirror of
https://github.com/weewx/weewx.git
synced 2026-04-18 16:46:56 -04:00
Fix OverflowError when a WU import encounters an abnormally high epoch timestamp (perhaps in milliseconds)
This commit is contained in:
@@ -295,9 +295,16 @@ class WUSource(weeimport.Source):
|
||||
# it's not there so skip it
|
||||
pass
|
||||
if obs == 'epoch':
|
||||
# An epoch timestamp could be in seconds or
|
||||
# milliseconds, WeeWX uses seconds. We can check by
|
||||
# trying to convert the epoch value into a datetime
|
||||
# object, if the epoch value is in milliseconds it will
|
||||
# fail. In that case divide the epoch value by 1000.
|
||||
# Note we would normally expect to see a ValueError but
|
||||
# on armhf platforms we might see an OverflowError.
|
||||
try:
|
||||
_date = datetime.date.fromtimestamp(_flat_record['epoch'])
|
||||
except ValueError:
|
||||
except (ValueError, OverflowError):
|
||||
_flat_record['epoch'] = _flat_record['epoch'] // 1000
|
||||
# WU in its wisdom provides min and max pressure but no average
|
||||
# pressure (unlike other obs) so we need to calculate it. If
|
||||
|
||||
Reference in New Issue
Block a user