Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2814)

Unified Diff: bin/ctest.py

Issue 4235001: Fix versioning logic in ctest to get the correct latest version. (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Nit Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bin/ctest.py
diff --git a/bin/ctest.py b/bin/ctest.py
index 70dbec8ffe2b43dcc411a4b27221d47fff0e58a6..c1c806e558dc73f220e20df4f3d0f43f0b32c0b1 100755
--- a/bin/ctest.py
+++ b/bin/ctest.py
@@ -93,6 +93,19 @@ def ModifyBootDesc(download_folder, redirect_file=None):
fileinput.close()
+def _GreaterVersion(version_a, version_b):
+ """Returns the higher version number of two version number strings."""
+ version_regex = re.compile('.*(\d+)\.(\d+)\.(\d+)\.(\d+).*')
+ version_a_tokens = version_regex.match(version_a).groups()
+ version_b_tokens = version_regex.match(version_b).groups()
+ for i in range(4):
+ (a, b) = (int(version_a_tokens[i]), int(version_b_tokens[i]))
+ if a != b:
+ if a > b: return version_a
+ return version_b
+ return version_a
+
+
def GetLatestLinkFromPage(url, regex):
"""Returns the latest link from the given url that matches regex.
@@ -102,12 +115,13 @@ def GetLatestLinkFromPage(url, regex):
"""
url_file = urllib.urlopen(url)
url_html = url_file.read()
+
url_file.close()
# Parses links with versions embedded.
url_parser = HTMLDirectoryParser(regex=regex)
url_parser.feed(url_html)
- return max(url_parser.link_list)
+ return reduce(_GreaterVersion, url_parser.link_list)
def GetNewestLinkFromZipBase(board, channel, zip_server_base):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698