Aufgrund einer Wartung wird GitLab am 25.01 zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 25.01 between 8:00 and 9:00 am.

Commit 5b995c60 authored by Jiahang Chen's avatar Jiahang Chen
Browse files

Merge branch 'add_network_error_exception' into 'master'

add network error handeling

See merge request !22
parents b6c767ae 88b775e9
Pipeline #597095 passed with stage
in 23 seconds
......@@ -9,7 +9,7 @@
from s3i.event_system import EventManager
from ml.s3i_tools import Broker, BrokerREST
from s3i.messages import GetValueReply, ServiceReply, SetValueReply, CustomEventReply
from s3i.exception import raise_error_from_s3ib_msg, S3IBMessageError
from s3i.exception import raise_error_from_s3ib_msg, S3IBMessageError, S3IDittoError, S3IIdentityProviderError
from ml.app_logger import APP_LOGGER
from ml.tools import find_broker_endpoint
from ml.callback import CallbackManager
......@@ -175,9 +175,12 @@ def __setup_identity_provider(self):
username=self.__username,
password=self.__password
)
self.__token = self.idp.get_token(TokenType.ACCESS_TOKEN)
APP_LOGGER.info("[S3I]: Access Token granted")
try:
self.__token = self.idp.get_token(TokenType.ACCESS_TOKEN)
except S3IIdentityProviderError as err:
APP_LOGGER.error("[S3I]: {}".format(err))
else:
APP_LOGGER.info("[S3I]: Access Token granted")
self.loop.call_later(self.__get_remaining_time_to_refresh(),
self.__refresh_token_recur)
self.callbacks.process_async_task(
......@@ -274,9 +277,12 @@ def __setup_event_system(self):
"""
def __recursively_update_directory(self, frequency):
self.dir.updateThingIDBased(thingID=self.identifier, payload=self.__entry.refresh_directory_entry(
current_dir_json=self.dir.queryThingIDBased(self.identifier)
))
try:
self.dir.updateThingIDBased(thingID=self.identifier, payload=self.__entry.refresh_directory_entry(
current_dir_json=self.dir.queryThingIDBased(self.identifier)
))
except S3IDittoError as err:
APP_LOGGER.error("[S3I]: {}".format(err))
if frequency != 0:
self.loop.call_later(
1 / frequency,
......@@ -285,7 +291,10 @@ def __recursively_update_directory(self, frequency):
)
def __recursively_update_repository(self, frequency):
self.repo.updateThingIDBased(thingID=self.identifier, payload=self.__entry.refresh_repository_entry())
try:
self.repo.updateThingIDBased(thingID=self.identifier, payload=self.__entry.refresh_repository_entry())
except S3IDittoError as err:
APP_LOGGER.error("[S3I]: {}".format(err))
if frequency != 0:
self.loop.call_later(
1 / frequency,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment