OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 # Push the {vers}/{plaform}/download_file_types.pb files to GCS so |
| 7 # that the component update system will pick them up and push them |
| 8 # to users. See README.md before running this. |
| 9 |
| 10 import optparse |
| 11 import os |
| 12 import subprocess |
| 13 import sys |
| 14 |
| 15 |
| 16 DEST_BUCKET = 'gs://chrome-component-file-type-policies' |
| 17 |
| 18 |
| 19 def main(): |
| 20 parser = optparse.OptionParser() |
| 21 parser.add_option('-d', '--dir', |
| 22 help='The directory containing ' |
| 23 '{vers}/{platform}/download_file_types.pb files.') |
| 24 |
| 25 (opts, args) = parser.parse_args() |
| 26 if opts.dir is None: |
| 27 parser.print_help() |
| 28 return 1 |
| 29 |
| 30 os.chdir(opts.dir) |
| 31 |
| 32 # Sanity check that we're in the right place |
| 33 assert opts.dir.endswith('/all'), '--dir should end with /all' |
| 34 dirs = os.listdir('.') |
| 35 assert (len(dirs) == 1 and dirs[0].isdigit()), ( |
| 36 'Should be exactly one version directory. Please delete the contents ' |
| 37 'of the target dir and regenerate the protos.') |
| 38 |
| 39 # Push the files with their directories, in the form |
| 40 # {vers}/{platform}/download_file_types.pb |
| 41 # Don't overwrite existing files, incase we forgot to increment the |
| 42 # version. |
| 43 vers_dir = dirs[0] |
| 44 command = ['gsutil', 'cp', '-Rn', vers_dir, DEST_BUCKET] |
| 45 |
| 46 print 'Going to run the following command' |
| 47 print ' ', ' '.join(command) |
| 48 print '\nIn directory' |
| 49 print ' ', opts.dir |
| 50 print '\nWhich should push the following files' |
| 51 expected_files = [os.path.join(dp, f) for dp, dn, fn in |
| 52 os.walk(vers_dir) for f in fn] |
| 53 for f in expected_files: |
| 54 print ' ', f |
| 55 |
| 56 shall = raw_input('\nAre you sure (y/N) ').lower() == 'y' |
| 57 if not shall: |
| 58 print 'aborting' |
| 59 return 1 |
| 60 return subprocess.call(command) |
| 61 |
| 62 |
| 63 if __name__ == '__main__': |
| 64 sys.exit(main()) |
| 65 |
OLD | NEW |