Wrap Google Fit checks in try-catch block to prevent the backend from crashing with no reload
This commit is contained in:
parent
7072a19829
commit
92f1f3eea7
1 changed files with 33 additions and 28 deletions
|
@ -66,6 +66,7 @@ class GoogleFitBackend(Backend):
|
||||||
self.logger.info('Scanning fit data source, last seen timestamp: {}'.
|
self.logger.info('Scanning fit data source, last seen timestamp: {}'.
|
||||||
format(str(datetime.datetime.fromtimestamp(last_timestamp))))
|
format(str(datetime.datetime.fromtimestamp(last_timestamp))))
|
||||||
|
|
||||||
|
try:
|
||||||
for data_source in self.data_sources:
|
for data_source in self.data_sources:
|
||||||
data_source_last_timestamp = 0
|
data_source_last_timestamp = 0
|
||||||
data_points = get_plugin('google.fit').get_data(
|
data_points = get_plugin('google.fit').get_data(
|
||||||
|
@ -94,12 +95,16 @@ class GoogleFitBackend(Backend):
|
||||||
self.logger.info('Got {} entries from data source {}, last timestamp: {}'.
|
self.logger.info('Got {} entries from data source {}, last timestamp: {}'.
|
||||||
format(len(data_points), data_source,
|
format(len(data_points), data_source,
|
||||||
str(datetime.datetime.fromtimestamp(data_source_last_timestamp))))
|
str(datetime.datetime.fromtimestamp(data_source_last_timestamp))))
|
||||||
|
|
||||||
|
|
||||||
last_timestamp = new_last_timestamp
|
last_timestamp = new_last_timestamp
|
||||||
|
|
||||||
get_plugin('variable').set(**{
|
get_plugin('variable').set(**{
|
||||||
self._last_timestamp_varname: last_timestamp})
|
self._last_timestamp_varname: last_timestamp})
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.warning('Exception while processing Fit data')
|
||||||
|
self.logger.exception(e)
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
time.sleep(self.poll_seconds)
|
time.sleep(self.poll_seconds)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue