Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] Add try-except on branch analyze action #26

Merged
merged 5 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions github_connector/models/github_repository_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,21 @@ 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)
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
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))
return True

# Compute Section
Expand Down
27 changes: 17 additions & 10 deletions github_connector_odoo/models/github_repository_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -141,3 +132,19 @@ 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.error('Cannot process module with name %s, error '
'is: %s' % (module_name, e))