OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Downloads a Firefox Nightly build for the current platform.""" | 6 """Downloads a Firefox Nightly build for the current platform.""" |
7 | 7 |
8 import datetime | 8 import datetime |
9 import glob | 9 import glob |
10 import os | 10 import os |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 downloader.download() | 87 downloader.download() |
88 print 'Downloaded %s' % firefox_archive | 88 print 'Downloaded %s' % firefox_archive |
89 return firefox_archive | 89 return firefox_archive |
90 except errors.NotFoundError as exception: | 90 except errors.NotFoundError as exception: |
91 print 'Failed to download firefox: %s.' % exception | 91 print 'Failed to download firefox: %s.' % exception |
92 fallback_build, age_days = _FindFallbackFirefoxBuild(target_dir) | 92 fallback_build, age_days = _FindFallbackFirefoxBuild(target_dir) |
93 | 93 |
94 if not fallback_build: | 94 if not fallback_build: |
95 raise Exception('We failed to download Firefox and we have no builds to ' | 95 raise Exception('We failed to download Firefox and we have no builds to ' |
96 'fall back on; failing...') | 96 'fall back on; failing...') |
97 if age_days > 7: | 97 if age_days > 14: |
98 raise Exception('We have failed to download firefox builds for more ' | 98 raise Exception('We have failed to download firefox builds for more ' |
99 'than 7 days now: failing so someone looks at it. The ' | 99 'than 14 days now: failing so someone looks at it. The ' |
100 'most recent build we have is %d days old.' % age_days) | 100 'most recent build we have is %d days old.' % age_days) |
101 | 101 |
102 print 'Using %s instead; it is %d days old.' % (fallback_build, age_days) | 102 print 'Using %s instead; it is %d days old.' % (fallback_build, age_days) |
103 return fallback_build | 103 return fallback_build |
104 | 104 |
105 | 105 |
106 def _ExtractArchive(firefox_archive, target_dir): | 106 def _ExtractArchive(firefox_archive, target_dir): |
107 if utils.GetPlatform() is 'linux': | 107 if utils.GetPlatform() is 'linux': |
108 tar_archive = tarfile.open(firefox_archive, 'r:bz2') | 108 tar_archive = tarfile.open(firefox_archive, 'r:bz2') |
109 tar_archive.extractall(path=target_dir) | 109 tar_archive.extractall(path=target_dir) |
(...skipping 29 matching lines...) Expand all Loading... |
139 | 139 |
140 firefox_archive = _MaybeDownload(target_dir, options.force) | 140 firefox_archive = _MaybeDownload(target_dir, options.force) |
141 if firefox_archive: | 141 if firefox_archive: |
142 _ExtractArchive(firefox_archive, target_dir) | 142 _ExtractArchive(firefox_archive, target_dir) |
143 | 143 |
144 if options.clean_old_firefox_archives: | 144 if options.clean_old_firefox_archives: |
145 _CleanOldFirefoxArchives(target_dir) | 145 _CleanOldFirefoxArchives(target_dir) |
146 | 146 |
147 if __name__ == '__main__': | 147 if __name__ == '__main__': |
148 sys.exit(main()) | 148 sys.exit(main()) |
OLD | NEW |