1#! /usr/bin/env python 2 3# Copyright 2018 Google LLC. 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6 7import os 8import subprocess 9import sys 10import time 11import urllib 12 13def gold_export_url(first_commit, last_commit): 14 query = [ 15 ('fbegin', first_commit), 16 ('fend', last_commit), 17 ('query', 'config=gles&config=vk&source_type=gm'), 18 ('pos', 'true'), 19 ('neg', 'false'), 20 ('unt', 'false') 21 ] 22 return 'https://public-gold.skia.org/json/export?' + urllib.urlencode(query) 23 24def git_rev_parse(rev): 25 return subprocess.check_output(['git', 'rev-parse', rev]).strip() 26 27def main(args): 28 if len(args) != 2: 29 sys.stderr.write('Usage:\n %s FIRST_COMMIT LAST_COMMIT\n' % __file__) 30 sys.exit(1) 31 c1 = git_rev_parse(args[0]) 32 c2 = git_rev_parse(args[1]) 33 now = time.strftime("%Y%m%d_%H%M%S", time.gmtime()) 34 url = gold_export_url(c1, c2) 35 sys.stdout.write(url + '\n') 36 filename = 'meta_%s_%s_%s.json' % (now, c1[:16], c2[:16]) 37 urllib.urlretrieve(url, filename) 38 sys.stdout.write('\n' + filename + '\n') 39 40if __name__ == '__main__': 41 main(sys.argv[1:]) 42 43