OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """ | 6 """ |
7 Convert the ASCII download_file_types.asciipb proto into a binary resource. | 7 Convert the ASCII download_file_types.asciipb proto into a binary resource. |
8 | 8 |
9 We generate a separate variant of the binary proto for each platform, | 9 We generate a separate variant of the binary proto for each platform, |
10 each which contains only the values that platform needs. | 10 each which contains only the values that platform needs. |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 # Make a separate file for each platform | 171 # Make a separate file for each platform |
172 for platform_type, platform_enum in PlatformTypes().iteritems(): | 172 for platform_type, platform_enum in PlatformTypes().iteritems(): |
173 # e.g. .../all/77/chromeos/download_file_types.pb | 173 # e.g. .../all/77/chromeos/download_file_types.pb |
174 outfile = os.path.join(opts.outdir, | 174 outfile = os.path.join(opts.outdir, |
175 str(full_pb.version_id), | 175 str(full_pb.version_id), |
176 platform_type, | 176 platform_type, |
177 opts.outbasename) | 177 opts.outbasename) |
178 MakeSubDirs(outfile) | 178 MakeSubDirs(outfile) |
179 FilterForPlatformAndWrite(full_pb, platform_enum, outfile) | 179 FilterForPlatformAndWrite(full_pb, platform_enum, outfile) |
180 | 180 |
181 print "\n\nTo push these files, run the following:" | |
182 print ("python " + | |
183 "chrome/browser/resources/safe_browsing/push_file_type_proto.py " + | |
184 "-d " + os.path.abspath(opts.outdir)) | |
185 print "\n\n" | |
186 | |
187 | 181 |
188 def main(): | 182 def main(): |
189 parser = optparse.OptionParser() | 183 parser = optparse.OptionParser() |
190 # TODO(nparker): Remove this once the bug is fixed. | 184 # TODO(nparker): Remove this once the bug is fixed. |
191 parser.add_option('-w', '--wrap', action="store_true", default=False, | 185 parser.add_option('-w', '--wrap', action="store_true", default=False, |
192 help='Wrap this script in another python ' | 186 help='Wrap this script in another python ' |
193 'execution to disable site-packages. This is a ' | 187 'execution to disable site-packages. This is a ' |
194 'fix for http://crbug.com/605592') | 188 'fix for http://crbug.com/605592') |
195 | 189 |
196 parser.add_option('-a', '--all', action="store_true", default=False, | 190 parser.add_option('-a', '--all', action="store_true", default=False, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 try: | 237 try: |
244 GenerateBinaryProtos(opts) | 238 GenerateBinaryProtos(opts) |
245 except Exception as e: | 239 except Exception as e: |
246 print "ERROR: Failed to render binary version of %s:\n %s\n%s" % ( | 240 print "ERROR: Failed to render binary version of %s:\n %s\n%s" % ( |
247 opts.infile, str(e), traceback.format_exc()) | 241 opts.infile, str(e), traceback.format_exc()) |
248 return 1 | 242 return 1 |
249 | 243 |
250 | 244 |
251 if __name__ == '__main__': | 245 if __name__ == '__main__': |
252 sys.exit(main()) | 246 sys.exit(main()) |
OLD | NEW |