| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 # Copyright (c) 2011 The Native Client 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 """Script to synchronise the naclports mirror of upstream archives. | 6 """Script to synchronise the naclports mirror of upstream archives. |
| 7 | 7 |
| 8 This script verifies that the URL for every package is mirrored on | 8 This script verifies that the URL for every package is mirrored on |
| 9 Google Cloud Storage. If it finds missing URLs it downloads them to | 9 Google Cloud Storage. If it finds missing URLs it downloads them to |
| 10 the local machine and then pushes them up using gsutil. | 10 the local machine and then pushes them up using gsutil. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 def GetMirrorListing(options, url): | 43 def GetMirrorListing(options, url): |
| 44 """Get filename listing for a Google cloud storage URL""" | 44 """Get filename listing for a Google cloud storage URL""" |
| 45 listing = subprocess.check_output([options.gsutil, 'ls', url]) | 45 listing = subprocess.check_output([options.gsutil, 'ls', url]) |
| 46 listing = listing.splitlines() | 46 listing = listing.splitlines() |
| 47 listing = [os.path.basename(l) for l in listing] | 47 listing = [os.path.basename(l) for l in listing] |
| 48 return listing | 48 return listing |
| 49 | 49 |
| 50 | 50 |
| 51 def CheckMirror(options, package, mirror_listing): | 51 def CheckMirror(options, package, mirror_listing): |
| 52 """Check that is package has is archive mirrors on Google cloud storage""" | 52 """Check that is package has is archive mirrors on Google cloud storage""" |
| 53 naclports.Trace('Checking %s' % package.NAME) | 53 naclports.LogVerbose('Checking %s' % package.NAME) |
| 54 basename = package.GetArchiveFilename() | 54 basename = package.GetArchiveFilename() |
| 55 if not basename: | 55 if not basename: |
| 56 return | 56 return |
| 57 | 57 |
| 58 if basename in mirror_listing: | 58 if basename in mirror_listing: |
| 59 # already mirrored | 59 # already mirrored |
| 60 return | 60 return |
| 61 | 61 |
| 62 if options.check: | 62 if options.check: |
| 63 naclports.Log('update_mirror: Archive missing from mirror: %s' % basename) | 63 naclports.Log('update_mirror: Archive missing from mirror: %s' % basename) |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 return CheckPackages(options, source_packages, listing) | 108 return CheckPackages(options, source_packages, listing) |
| 109 | 109 |
| 110 | 110 |
| 111 if __name__ == '__main__': | 111 if __name__ == '__main__': |
| 112 try: | 112 try: |
| 113 sys.exit(main(sys.argv[1:])) | 113 sys.exit(main(sys.argv[1:])) |
| 114 except naclports.Error as e: | 114 except naclports.Error as e: |
| 115 sys.stderr.write('%s\n' % e) | 115 sys.stderr.write('%s\n' % e) |
| 116 sys.exit(-1) | 116 sys.exit(-1) |
| OLD | NEW |