From 0d369ccb6288e21cb2463e9662c4fd75c675304d Mon Sep 17 00:00:00 2001 From: Stephan Rozendaal Date: Tue, 2 Oct 2018 15:29:57 +0200 Subject: [PATCH 1/5] [IMP] Add try-except on branch analyze action Add try-except statements on analyze actions that could potentially crash the analyze process. --- .../models/github_repository_branch.py | 7 ++++- .../models/github_repository_branch.py | 28 ++++++++++++------- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/github_connector/models/github_repository_branch.py b/github_connector/models/github_repository_branch.py index 76f89b47..3e1502f2 100644 --- a/github_connector/models/github_repository_branch.py +++ b/github_connector/models/github_repository_branch.py @@ -222,7 +222,12 @@ def _analyze_code(self): "Warning Folder %s not found: Analysis skipped." % path) else: _logger.info("Analyzing Source Code in %s ..." % path) - vals = branch.analyze_code_one(branch) + try: + vals = branch.analyze_code_one(branch) + except Exception as e: + _logger.warning( + 'Cannot analyze branch %s so skipping it, error ' + 'is: %s' % (branch.name, e.message)) vals.update({ 'last_analyze_date': datetime.today(), 'state': 'analyzed', diff --git a/github_connector_odoo/models/github_repository_branch.py b/github_connector_odoo/models/github_repository_branch.py index f6b5f237..ad39ac58 100644 --- a/github_connector_odoo/models/github_repository_branch.py +++ b/github_connector_odoo/models/github_repository_branch.py @@ -109,16 +109,7 @@ def analyze_code_one(self, branch): # Analyze folders and create module versions _logger.info("Analyzing repository %s ..." % path) for module_name in self.listdir(path): - full_module_path = os.path.join(path, module_name) - module_info = load_information_from_description_file( - module_name, full_module_path) - - # Create module version, if the module is installable - # in the serie - if module_info.get('installable', False): - module_info['technical_name'] = module_name - module_version_obj.create_or_update_from_manifest( - module_info, branch, full_module_path) + self._analyze_module_name(path, module_name, branch) finally: # Reset Original level for module logger logger1.setLevel(currentLevel1) @@ -141,3 +132,20 @@ def is_really_module(name): return True return map(clean, filter(is_really_module, os.listdir(dir))) + + def _analyze_module_name(self, path, module_name, branch): + module_version_obj = self.env['odoo.module.version'] + try: + full_module_path = os.path.join(path, module_name) + module_info = load_information_from_description_file( + module_name, full_module_path) + # Create module version, if the module is installable + # in the serie + if module_info.get('installable', False): + module_info['technical_name'] = module_name + module_version_obj.create_or_update_from_manifest( + module_info, branch, full_module_path) + except Exception as e: + _logger.warning('Cannot process module with name %s, error ' + 'is: %s' % ( + module_info['technical_name'], e.message)) From cfaf1ebcb168f52d4729cacba8a1abe9ac4f4b87 Mon Sep 17 00:00:00 2001 From: Stephan Rozendaal Date: Tue, 2 Oct 2018 15:44:33 +0200 Subject: [PATCH 2/5] [REF] Fix error logging Changes include: - fix error values - use error instead of warning --- github_connector_odoo/models/github_repository_branch.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/github_connector_odoo/models/github_repository_branch.py b/github_connector_odoo/models/github_repository_branch.py index ad39ac58..44a47dde 100644 --- a/github_connector_odoo/models/github_repository_branch.py +++ b/github_connector_odoo/models/github_repository_branch.py @@ -146,6 +146,5 @@ def _analyze_module_name(self, path, module_name, branch): module_version_obj.create_or_update_from_manifest( module_info, branch, full_module_path) except Exception as e: - _logger.warning('Cannot process module with name %s, error ' - 'is: %s' % ( - module_info['technical_name'], e.message)) + _logger.error('Cannot process module with name %s, error ' + 'is: %s' % (module_name, e)) From c6faf6753637b63e391c08909cc32c4ab37300d2 Mon Sep 17 00:00:00 2001 From: Stephan Rozendaal Date: Tue, 2 Oct 2018 15:49:15 +0200 Subject: [PATCH 3/5] [IMP] Fix error in analyze call Fix a programming mistake in the analyze call. By @RoelAdriaans --- .../models/github_repository_branch.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/github_connector/models/github_repository_branch.py b/github_connector/models/github_repository_branch.py index 3e1502f2..79870db1 100644 --- a/github_connector/models/github_repository_branch.py +++ b/github_connector/models/github_repository_branch.py @@ -224,18 +224,19 @@ def _analyze_code(self): _logger.info("Analyzing Source Code in %s ..." % path) try: vals = branch.analyze_code_one(branch) + vals.update({ + 'last_analyze_date': datetime.today(), + 'state': 'analyzed', + }) + # Mark the branch as analyzed + branch.write(vals) + if partial_commit: + self._cr.commit() # pylint: disable=invalid-commit + except Exception as e: _logger.warning( 'Cannot analyze branch %s so skipping it, error ' - 'is: %s' % (branch.name, e.message)) - vals.update({ - 'last_analyze_date': datetime.today(), - 'state': 'analyzed', - }) - # Mark the branch as analyzed - branch.write(vals) - if partial_commit: - self._cr.commit() # pylint: disable=invalid-commit + 'is: %s' % (branch.name, e)) return True # Compute Section From 513d505fefc63e00cae152ebe8a0509db63dd0c5 Mon Sep 17 00:00:00 2001 From: Stephan Rozendaal Date: Tue, 2 Oct 2018 16:24:35 +0200 Subject: [PATCH 4/5] [IMP] Bump version number of github_connector Bump the version number of github_connector to '11.0.1.1.1'. --- github_connector/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github_connector/__manifest__.py b/github_connector/__manifest__.py index 902d296d..0505d222 100644 --- a/github_connector/__manifest__.py +++ b/github_connector/__manifest__.py @@ -5,7 +5,7 @@ { 'name': 'Github Connector', 'summary': 'Synchronize information from Github repositories', - 'version': '11.0.1.1.0', + 'version': '11.0.1.1.1', 'category': 'Connector', 'license': 'AGPL-3', 'author': From 3bc2cbe5f6a991177e9e2ec2468ac65d2cb1985f Mon Sep 17 00:00:00 2001 From: Stephan Rozendaal Date: Tue, 2 Oct 2018 16:25:49 +0200 Subject: [PATCH 5/5] [IMP] Bump version number of github_connector Bump the version number of github_connector_odoo to '11.0.1.1.1'. --- github_connector_odoo/__manifest__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github_connector_odoo/__manifest__.py b/github_connector_odoo/__manifest__.py index 02e62366..59b379bd 100644 --- a/github_connector_odoo/__manifest__.py +++ b/github_connector_odoo/__manifest__.py @@ -4,7 +4,7 @@ { 'name': 'Github Connector - Odoo', 'summary': 'Analyze Odoo modules information from Github repositories', - 'version': '11.0.1.1.0', + 'version': '11.0.1.1.1', 'category': 'Connector', 'license': 'AGPL-3', 'author': 'Odoo Community Association (OCA), Sylvain LE GAL, GRAP',