OLD | NEW |
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import base64 | 5 import base64 |
6 import json | 6 import json |
7 import os | 7 import os |
| 8 import time |
| 9 import urllib2 |
8 | 10 |
9 from common import utils | 11 from common import utils |
10 | 12 |
11 | 13 |
12 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | 14 _THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
13 CONFIG = json.loads(open(os.path.join(_THIS_DIR, | 15 CONFIG = json.loads(open(os.path.join(_THIS_DIR, |
14 'deps_config.json'), 'r').read()) | 16 'deps_config.json'), 'r').read()) |
15 | 17 |
16 | 18 |
17 class _VarImpl(object): | 19 class _VarImpl(object): |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 name = path.split('/')[0].lower() | 59 name = path.split('/')[0].lower() |
58 if name in components_renamed: | 60 if name in components_renamed: |
59 return components_renamed[name].lower() | 61 return components_renamed[name].lower() |
60 else: | 62 else: |
61 return name.lower() | 63 return name.lower() |
62 | 64 |
63 # Unknown path, return the whole path as component name. | 65 # Unknown path, return the whole path as component name. |
64 return '_'.join(path.split('/')) | 66 return '_'.join(path.split('/')) |
65 | 67 |
66 | 68 |
67 def _GetContentOfDEPS(url): | 69 def _GetContentOfDEPS(url, retries=5, sleep_time=0.1): |
68 _, content = utils.GetHttpClient().Get(url, timeout=60) | 70 count = 0 |
69 return content | 71 while True: |
| 72 count += 1 |
| 73 try: |
| 74 _, content = utils.GetHttpClient().Get(url, timeout=60) |
| 75 return content |
| 76 |
| 77 # TODO(jeun): Handle HTTP Errors, such as 404. |
| 78 except urllib2.HTTPError: |
| 79 if count < retries: |
| 80 time.sleep(sleep_time) |
| 81 else: |
| 82 break |
| 83 |
| 84 return '' |
70 | 85 |
71 | 86 |
72 def GetChromiumComponents(chromium_revision, | 87 def GetChromiumComponents(chromium_revision, |
73 os_platform='unix', | 88 os_platform='unix', |
74 deps_file_downloader=_GetContentOfDEPS): | 89 deps_file_downloader=_GetContentOfDEPS): |
75 """Return a list of components used by Chrome of the given revision. | 90 """Return a list of components used by Chrome of the given revision. |
76 | 91 |
77 Args: | 92 Args: |
78 chromium_revision: The revision of the Chrome build. | 93 chromium_revision: The revision of the Chrome build. |
79 os_platform: The target platform of the Chrome build, eg. win, mac, etc. | 94 os_platform: The target platform of the Chrome build, eg. win, mac, etc. |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 'path': path, | 213 'path': path, |
199 'rolled': new_component['revision'] != old_revision, | 214 'rolled': new_component['revision'] != old_revision, |
200 'name': new_component['name'], | 215 'name': new_component['name'], |
201 'old_revision': old_revision, | 216 'old_revision': old_revision, |
202 'new_revision': new_component['revision'], | 217 'new_revision': new_component['revision'], |
203 'repository': new_component['repository'], | 218 'repository': new_component['repository'], |
204 'repository_type': new_component['repository_type'] | 219 'repository_type': new_component['repository_type'] |
205 } | 220 } |
206 | 221 |
207 return components | 222 return components |
OLD | NEW |