Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: chrome/browser/resources/safe_browsing/push_file_type_proto.py

Issue 2003323003: Script to push download_file_types.pb to all platforms, via Component Updater (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit in README.gn Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698