adding logger info when the connection is fail
This commit is contained in:
parent
c21d54dcb5
commit
3d171626f3
|
@ -12,11 +12,17 @@ from teal.resource import Resource, View
|
||||||
from ereuse_devicehub.resources.inventory.model import Inventory
|
from ereuse_devicehub.resources.inventory.model import Inventory
|
||||||
|
|
||||||
|
|
||||||
def get_tag_version():
|
def get_tag_version(app):
|
||||||
"""Get version of microservice ereuse-tag."""
|
"""Get version of microservice ereuse-tag."""
|
||||||
|
|
||||||
path = "/versions/version/"
|
path = "/versions/version/"
|
||||||
url = urlparse(Inventory.current.tag_provider.to_text())._replace(path=path)
|
url = urlparse(Inventory.current.tag_provider.to_text())._replace(path=path)
|
||||||
res = requests.get(url.geturl())
|
try:
|
||||||
|
res = requests.get(url.geturl())
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
app.logger.error("The microservice Tags is down!!")
|
||||||
|
return {}
|
||||||
|
|
||||||
if res.status_code == 200:
|
if res.status_code == 200:
|
||||||
return json.loads(res.content)
|
return json.loads(res.content)
|
||||||
else:
|
else:
|
||||||
|
@ -25,9 +31,10 @@ def get_tag_version():
|
||||||
class VersionView(View):
|
class VersionView(View):
|
||||||
def get(self, *args, **kwargs):
|
def get(self, *args, **kwargs):
|
||||||
"""Get version of DeviceHub and ereuse-tag."""
|
"""Get version of DeviceHub and ereuse-tag."""
|
||||||
|
|
||||||
dh_version = pkg_resources.require('ereuse-devicehub')[0].version
|
dh_version = pkg_resources.require('ereuse-devicehub')[0].version
|
||||||
tag_version = get_tag_version()
|
tag_version = get_tag_version(self.resource_def.app)
|
||||||
versions = {'devicehub': dh_version}
|
versions = {'devicehub': dh_version, "ereuse_tag": "0.0.0"}
|
||||||
versions.update(tag_version)
|
versions.update(tag_version)
|
||||||
return json.dumps(versions)
|
return json.dumps(versions)
|
||||||
|
|
||||||
|
@ -40,9 +47,9 @@ class VersionDef(Resource):
|
||||||
|
|
||||||
def __init__(self, app,
|
def __init__(self, app,
|
||||||
import_name=__name__,
|
import_name=__name__,
|
||||||
static_folder='static',
|
static_folder=None,
|
||||||
static_url_path=None,
|
static_url_path=None,
|
||||||
template_folder='templates',
|
template_folder=None,
|
||||||
url_prefix=None,
|
url_prefix=None,
|
||||||
subdomain=None,
|
subdomain=None,
|
||||||
url_defaults=None,
|
url_defaults=None,
|
||||||
|
@ -51,7 +58,7 @@ class VersionDef(Resource):
|
||||||
super().__init__(app, import_name, static_folder, static_url_path, template_folder,
|
super().__init__(app, import_name, static_folder, static_url_path, template_folder,
|
||||||
url_prefix, subdomain, url_defaults, root_path, cli_commands)
|
url_prefix, subdomain, url_defaults, root_path, cli_commands)
|
||||||
|
|
||||||
d = {'devicehub': '0.1.0a'}
|
d = {'devicehub': '1.0a'}
|
||||||
get = {'GET'}
|
get = {'GET'}
|
||||||
|
|
||||||
version_view = VersionView.as_view('VersionView', definition=self)
|
version_view = VersionView.as_view('VersionView', definition=self)
|
||||||
|
|
Reference in New Issue