blob: cdac8006941950a1a218dd2fd8f542dea3f84824 [file] [log] [blame]
llozano9efafde2013-02-23 01:37:04 +00001#!/usr/bin/python
2#
3# Copyright 2013 Google Inc. All Rights Reserved.
4
5"""Script to find list of common images (first beta releases) in Chromeos.
6
7Display information about stable ChromeOS/Chrome versions to be used
8by the team developers. The purpose is to increase team productivity
9by using stable (known and tested) ChromeOS/Chrome versions instead of
10using randomly selected versions. Currently we define as a "stable"
11version the first Beta release in a particular release cycle.
12"""
13
14__author__ = "llozano@google.com (Luis Lozano)"
15
16import optparse
17import pickle
18import re
19import sys
20import urllib
21
22VERSIONS_HISTORY_URL = "http://cros-omahaproxy.appspot.com/history"
23
24
25def DisplayBetas(betas):
26 print "List of betas from", VERSIONS_HISTORY_URL
27 for beta in betas:
28 print " Release", beta["chrome_major_version"], beta
29 return
30
31
32def FindAllBetas(all_versions):
33 """Get ChromeOS first betas from History URL."""
34
35 all_betas = []
36 prev_beta = {}
37 for line in all_versions:
38 match_obj = re.match(
39 r"(?P<date>.*),(?P<chromeos_version>.*),"
40 r"(?P<chrome_major_version>\d*).(?P<chrome_minor_version>.*),"
41 r"(?P<chrome_appid>.*),beta-channel,,Samsung Chromebook Series 5 550",
42 line)
43 if match_obj:
44 if prev_beta:
45 if (prev_beta["chrome_major_version"] !=
46 match_obj.group("chrome_major_version")):
47 all_betas.append(prev_beta)
48 prev_beta = match_obj.groupdict()
49 if prev_beta:
50 all_betas.append(prev_beta)
51 return all_betas
52
53
54def SerializeBetas(all_betas, serialize_file):
55 with open(serialize_file, "wb") as f:
56 pickle.dump(all_betas, f)
57 print "Serialized list of betas into", serialize_file
58 return
59
60
61def Main(argv):
62 """Get ChromeOS first betas list from history URL."""
63
64 parser = optparse.OptionParser()
65 parser.add_option("--serialize", dest="serialize", default=None,
66 help="Save list of common images into the specified file.")
67 options = parser.parse_args(argv)[0]
68
69 try:
70 opener = urllib.URLopener()
71 all_versions = opener.open(VERSIONS_HISTORY_URL)
72 except IOError as ioe:
73 print "Cannot open", VERSIONS_HISTORY_URL
74 print ioe
75 return 1
76
77 all_betas = FindAllBetas(all_versions)
78 DisplayBetas(all_betas)
79 if options.serialize:
80 SerializeBetas(all_betas, options.serialize)
81 all_versions.close()
82
83 return 0
84
85if __name__ == "__main__":
86 retval = Main(sys.argv)
87 sys.exit(retval)