Skip to content

Commit

Permalink
Add #1 and #2 pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Moreau committed Jan 7, 2015
2 parents 4593c6f + 067e323 commit d56d5b6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
25 changes: 16 additions & 9 deletions sauron/drupal/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,17 @@ def get_module_update_info(module, version, core_version_major):

""" Call update service """
content = requests.get(url + '/' + module + '/' + core_version_major + '.x')

root = ET.fromstring(content.text.encode('ascii', 'ignore'))
title = root.find('title')
if ET.iselement(title):
releases = root.find('releases')
recommended_major = root.find('recommended_major')
if ET.iselement(recommended_major):
recommended_major = recommended_major.text
last_bug_fix = ''
last_security_fix = ''
last_recommended = ''
last_bug_rank = 0
last_security_rank = 0
current_rank = 0
Expand All @@ -182,6 +186,8 @@ def get_module_update_info(module, version, core_version_major):
continue
if v == version:
current_rank = rank
if major_v == recommended_major and last_recommended == '':
last_recommended = v
terms = release.findall(".//terms/term")
for term in terms:
if term.find('name').text == 'Release type':
Expand All @@ -199,8 +205,9 @@ def get_module_update_info(module, version, core_version_major):
info['last_security_rank'] = last_security_rank
info['last_bug_fix'] = last_bug_fix
info['last_bug_rank'] = last_bug_rank
info['last_recommended'] = last_recommended
info['current_rank'] = current_rank

return info


Expand All @@ -215,17 +222,17 @@ def generate_report(core_info, module_infos):
0 => True if security issue has been detected, False otherwise
1 => HTML report
"""
header = ['Module', 'Installed version', 'Last security update version', 'Last bug fix version']
header = ['Module', 'Installed version', 'Last security update version', 'Last bug fix version', 'Last recommended version']
has_sec_issue = False
colors = ['#DDFFDD', '#FFFFDD', '#FFCCCC']

core_table = HTML.Table(header_row=header)
issue_level = _has_issue(core_info)
if issue_level == 2:
has_sec_issue = True
row = [core_info['title'], core_info['current_version'], core_info['last_security_fix'], core_info['last_bug_fix']]
trow = HTML.TableRow(row, bgcolor=colors[issue_level])

core_table.rows.append(trow)

modules_table = HTML.Table(header_row=header)
Expand All @@ -234,14 +241,14 @@ def generate_report(core_info, module_infos):
if issue_level == 2:
has_sec_issue = True

row = [info['title'], info['current_version'], info['last_security_fix'], info['last_bug_fix']]
row = [info['title'], info['current_version'], info['last_security_fix'], info['last_bug_fix'], info['last_recommended']]
trow = HTML.TableRow(row, bgcolor=colors[issue_level])

modules_table.rows.append(trow)

head = "This is the update status report of your site " + env.project['project']
content = head + "<br /><br />" + str(core_table) + "<br /><br />" + str(modules_table)

return has_sec_issue, content


Expand Down

0 comments on commit d56d5b6

Please sign in to comment.