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

Side by Side 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, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # 2 #
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Wrapper for tests that are run on builders.""" 7 """Wrapper for tests that are run on builders."""
8 8
9 import fileinput 9 import fileinput
10 import optparse 10 import optparse
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 Info('Replacing line %s with %s' % (line, new_line)) 86 Info('Replacing line %s with %s' % (line, new_line))
87 redirect_file.write('%s\n' % new_line) 87 redirect_file.write('%s\n' % new_line)
88 continue 88 continue
89 89
90 # Line does not need to be modified. 90 # Line does not need to be modified.
91 redirect_file.write(line) 91 redirect_file.write(line)
92 92
93 fileinput.close() 93 fileinput.close()
94 94
95 95
96 def _GreaterVersion(version_a, version_b):
97 """Returns the higher version number of two version number strings."""
98 version_regex = re.compile('.*(\d+)\.(\d+)\.(\d+)\.(\d+).*')
99 version_a_tokens = version_regex.match(version_a).groups()
100 version_b_tokens = version_regex.match(version_b).groups()
101 for i in range(4):
102 (a, b) = (int(version_a_tokens[i]), int(version_b_tokens[i]))
103 if a != b:
104 if a > b: return version_a
105 return version_b
106 return version_a
107
108
96 def GetLatestLinkFromPage(url, regex): 109 def GetLatestLinkFromPage(url, regex):
97 """Returns the latest link from the given url that matches regex. 110 """Returns the latest link from the given url that matches regex.
98 111
99 Args: 112 Args:
100 url: Url to download and parse. 113 url: Url to download and parse.
101 regex: Regular expression to match links against. 114 regex: Regular expression to match links against.
102 """ 115 """
103 url_file = urllib.urlopen(url) 116 url_file = urllib.urlopen(url)
104 url_html = url_file.read() 117 url_html = url_file.read()
118
105 url_file.close() 119 url_file.close()
106 120
107 # Parses links with versions embedded. 121 # Parses links with versions embedded.
108 url_parser = HTMLDirectoryParser(regex=regex) 122 url_parser = HTMLDirectoryParser(regex=regex)
109 url_parser.feed(url_html) 123 url_parser.feed(url_html)
110 return max(url_parser.link_list) 124 return reduce(_GreaterVersion, url_parser.link_list)
111 125
112 126
113 def GetNewestLinkFromZipBase(board, channel, zip_server_base): 127 def GetNewestLinkFromZipBase(board, channel, zip_server_base):
114 """Returns the url to the newest image from the zip server. 128 """Returns the url to the newest image from the zip server.
115 129
116 Args: 130 Args:
117 board: board for the image zip. 131 board: board for the image zip.
118 channel: channel for the image zip. 132 channel: channel for the image zip.
119 zip_server_base: base url for zipped images. 133 zip_server_base: base url for zipped images.
120 """ 134 """
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 options.remote) 294 options.remote)
281 295
282 296
283 if __name__ == '__main__': 297 if __name__ == '__main__':
284 try: 298 try:
285 main() 299 main()
286 except Exception: 300 except Exception:
287 print "Got exception." 301 print "Got exception."
288 traceback.print_exc(file=sys.stdout) 302 traceback.print_exc(file=sys.stdout)
289 303
OLDNEW
« 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