From 83182ee9d4b0abc110c35c5a0882f230a39c0182 Mon Sep 17 00:00:00 2001 From: "Laurent Mignon (ACSONE)" Date: Thu, 5 Jan 2017 10:18:14 +0100 Subject: [PATCH] [IMP] Protect import of external lib to prevent error when the module is put in an addons path without the external lib installed This error should never occur since if you put this project into your addon path you want to use it and without the lib it don't work. But Travis CI fails if these imports are not protected due to a stupid rule enforced in odoo-pylint (Oct, 11, 2016) https://github.com/OCA/maintainer-quality-tools/pull/354 --- cmis/models/cmis_backend.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmis/models/cmis_backend.py b/cmis/models/cmis_backend.py index c0fb966..1996297 100644 --- a/cmis/models/cmis_backend.py +++ b/cmis/models/cmis_backend.py @@ -4,10 +4,6 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). import logging -import cmislib.exceptions -from cmislib.model import CmisClient -from cmislib.browser.binding import BrowserBinding -from cmislib.exceptions import ObjectNotFoundException from openerp import api, fields, models from openerp.exceptions import UserError @@ -16,6 +12,14 @@ _logger = logging.getLogger(__name__) +try: + import cmislib.exceptions + from cmislib.model import CmisClient + from cmislib.browser.binding import BrowserBinding + from cmislib.exceptions import ObjectNotFoundException +except (ImportError, IOError) as err: + _logger.debug(err) + class CmisBackend(models.Model): _name = 'cmis.backend'