| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 """Utility to package and upload the USB gadget framework. | 6 """Utility to package and upload the USB gadget framework. |
| 7 """ | 7 """ |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import hashlib | 10 import hashlib |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 '--upload', type=str, metavar='HOST[:PORT]', | 75 '--upload', type=str, metavar='HOST[:PORT]', |
| 76 help='upload package to target system') | 76 help='upload package to target system') |
| 77 parser.add_argument( | 77 parser.add_argument( |
| 78 'files', metavar='FILE', type=str, nargs='*', | 78 'files', metavar='FILE', type=str, nargs='*', |
| 79 help='source files') | 79 help='source files') |
| 80 | 80 |
| 81 args = parser.parse_args() | 81 args = parser.parse_args() |
| 82 | 82 |
| 83 content, md5 = MakeZip(directory=args.dir, files=args.files) | 83 content, md5 = MakeZip(directory=args.dir, files=args.files) |
| 84 if args.zip_file: | 84 if args.zip_file: |
| 85 with open(args.zip_file, 'w') as zip_file: | 85 with open(args.zip_file, 'wb') as zip_file: |
| 86 zip_file.write(content) | 86 zip_file.write(content) |
| 87 if args.hash_file: | 87 if args.hash_file: |
| 88 with open(args.hash_file, 'w') as hash_file: | 88 with open(args.hash_file, 'wb') as hash_file: |
| 89 hash_file.write(md5) | 89 hash_file.write(md5) |
| 90 if args.upload: | 90 if args.upload: |
| 91 UploadZip(content, md5, args.upload) | 91 UploadZip(content, md5, args.upload) |
| 92 | 92 |
| 93 | 93 |
| 94 if __name__ == '__main__': | 94 if __name__ == '__main__': |
| 95 main() | 95 main() |
| OLD | NEW |