| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 | 2 |
| 3 # Copyright 2015 Google Inc. | 3 # Copyright 2015 Google Inc. |
| 4 # | 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be | 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. | 6 # found in the LICENSE file. |
| 7 | 7 |
| 8 | 8 |
| 9 import os | 9 import contextlib |
| 10 import subprocess | |
| 11 import sys | 10 import sys |
| 12 | 11 import urllib2 |
| 13 sys.path.insert(0, os.path.join('common', 'py', 'utils')) | |
| 14 import gs_utils | |
| 15 | 12 |
| 16 | 13 |
| 17 def get_uploaded_hashes(gs_bucket, gs_dir): | 14 HASHES_URL = 'https://gold.skia.org/2/_/hashes' |
| 18 _, files = gs_utils.GSUtils().list_bucket_contents(gs_bucket, subdir=gs_dir) | |
| 19 hashes = [] | |
| 20 for line in files: | |
| 21 hashes.append(os.path.basename(line).split('.')[0]) | |
| 22 return hashes | |
| 23 | 15 |
| 24 | 16 |
| 25 def main(gs_bucket, gs_dir, output_file): | 17 def main(output_file): |
| 26 hashes = get_uploaded_hashes(gs_bucket, gs_dir) | |
| 27 with open(output_file, 'w') as f: | 18 with open(output_file, 'w') as f: |
| 28 for h in hashes: | 19 with contextlib.closing(urllib2.urlopen(HASHES_URL)) as w: |
| 29 f.write(h + '\n') | 20 f.write(w.read()) |
| 30 | 21 |
| 31 | 22 |
| 32 if __name__ == '__main__': | 23 if __name__ == '__main__': |
| 33 if len(sys.argv) != 4: | 24 if len(sys.argv) != 2: |
| 34 print >> sys.stderr , ('Usage: %s <gs_bucket> <gs_subdir> <output_file>' % | 25 print >> sys.stderr , 'Usage: %s <output_file>' % sys.argv[0] |
| 35 sys.argv[0]) | |
| 36 sys.exit(1) | 26 sys.exit(1) |
| 37 main(*sys.argv[1:]) | 27 main(*sys.argv[1:]) |
| OLD | NEW |