| #!/usr/bin/env python |
| # |
| # Copyright 2014 Google Inc. All Rights Reserved. |
| |
| """Utility to get the ota size for all Chromecast builds. |
| |
| It will fetch the ota stored in bigstore and report the size of them in a csv. |
| """ |
| |
| import optparse |
| import re |
| import subprocess |
| |
| # Command to list all builds. |
| GET_OTA_INFO_CMD = ('gsutil ls -l gs://gtv-eureka/internal/%s/anchovy-eng/*/' |
| 'anchovy-ota-*.zip') |
| GET_OTA_RE = re.compile(r'\s+([0-9]+)\s+.*anchovy-ota-([0-9]+)\.zip') |
| |
| |
| def ParseArgs(): |
| """Parse args.""" |
| parser = optparse.OptionParser() |
| parser.add_option('--branch', default='merge29', help=('Branch to get ota')) |
| parser.add_option('--output_csv', default='build_size.csv', help=('Csv')) |
| options = parser.parse_args()[0] |
| return options |
| |
| |
| def GetOtaInfo(branch, output_csv): |
| """Returns the ota size and build number in a csv file.""" |
| ota_info_list = [] |
| with open('/tmp/ota_info.txt', 'w') as f: |
| subprocess.call(GET_OTA_INFO_CMD % branch, shell=True, stdout=f) |
| with open('/tmp/ota_info.txt', 'r') as f: |
| ota_info_list = f.readlines() |
| if ota_info_list: |
| with open(output_csv, 'w') as f: |
| for ota in ota_info_list: |
| info = GET_OTA_RE.search(ota) |
| if info: |
| f.write(','.join((info.group(2), info.group(1)))+'\n') |
| |
| FLAGS = ParseArgs() |
| |
| |
| def main(): |
| GetOtaInfo(FLAGS.branch, FLAGS.output_csv) |
| |
| if __name__ == '__main__': |
| main() |