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

Side by Side Diff: native_client_sdk/src/tools/oshelpers.py

Issue 11428111: [NaCl SDK] Fix zip_test failure on mac buildbots. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added correct ZipInfo Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | native_client_sdk/src/tools/zip_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 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 import fnmatch 6 import fnmatch
7 import glob 7 import glob
8 import optparse 8 import optparse
9 import os 9 import os
10 import posixpath 10 import posixpath
11 import shutil 11 import shutil
12 import stat
12 import sys 13 import sys
13 import time 14 import time
14 import zipfile 15 import zipfile
15 16
16 17
17 def IncludeFiles(filters, files): 18 def IncludeFiles(filters, files):
18 """Filter files based on inclusion lists 19 """Filter files based on inclusion lists
19 20
20 Return a list of files which match and of the Unix shell-style wildcards 21 Return a list of files which match and of the Unix shell-style wildcards
21 provided, or return all the files if no filter is provided.""" 22 provided, or return all the files if no filter is provided."""
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 419
419 try: 420 try:
420 zip_stream = zipfile.ZipFile(dest_zip, write_mode, zipfile.ZIP_DEFLATED) 421 zip_stream = zipfile.ZipFile(dest_zip, write_mode, zipfile.ZIP_DEFLATED)
421 for os_path, file_info_or_zip_path, file_bytes in zip_data: 422 for os_path, file_info_or_zip_path, file_bytes in zip_data:
422 if isinstance(file_info_or_zip_path, zipfile.ZipInfo): 423 if isinstance(file_info_or_zip_path, zipfile.ZipInfo):
423 zip_path = file_info_or_zip_path.filename 424 zip_path = file_info_or_zip_path.filename
424 else: 425 else:
425 zip_path = file_info_or_zip_path 426 zip_path = file_info_or_zip_path
426 427
427 if os_path: 428 if os_path:
428 zip_stream.write(os_path, zip_path) 429 st = os.stat(os_path)
430 if stat.S_ISDIR(st.st_mode):
431 # Python 2.6 on the buildbots doesn't support writing directories to
432 # zip files. This was resolved in a later version of Python 2.6.
433 # We'll work around it by writing an empty file with the correct
434 # path. (This is basically what later versions do anyway.)
435 zip_info = zipfile.ZipInfo()
436 zip_info.filename = zip_path
437 zip_info.date_time = time.localtime(st.st_mtime)[0:6]
438 zip_info.compress_type = zip_stream.compression
439 zip_info.flag_bits = 0x00
440 zip_info.external_attr = (st[0] & 0xFFFF) << 16L
441 zip_info.CRC = 0
442 zip_info.compress_size = 0
443 zip_info.file_size = 0
444 zip_stream.writestr(zip_info, '')
445 else:
446 zip_stream.write(os_path, zip_path)
429 else: 447 else:
430 zip_stream.writestr(file_info_or_zip_path, file_bytes) 448 zip_stream.writestr(file_info_or_zip_path, file_bytes)
431 449
432 if not options.quiet: 450 if not options.quiet:
433 if zip_path in new_files_to_add: 451 if zip_path in new_files_to_add:
434 operation = 'adding' 452 operation = 'adding'
435 else: 453 else:
436 operation = 'updating' 454 operation = 'updating'
437 zip_info = zip_stream.getinfo(zip_path) 455 zip_info = zip_stream.getinfo(zip_path)
438 if (zip_info.compress_type == zipfile.ZIP_STORED or 456 if (zip_info.compress_type == zipfile.ZIP_STORED or
(...skipping 24 matching lines...) Expand all
463 return 1 481 return 1
464 func = FuncMap.get(args[0]) 482 func = FuncMap.get(args[0])
465 if not func: 483 if not func:
466 print 'Do not recognize command: ' + args[0] 484 print 'Do not recognize command: ' + args[0]
467 print 'Available commands: %s' % ' '.join(FuncMap) 485 print 'Available commands: %s' % ' '.join(FuncMap)
468 return 1 486 return 1
469 return func(args[1:]) 487 return func(args[1:])
470 488
471 if __name__ == '__main__': 489 if __name__ == '__main__':
472 sys.exit(main(sys.argv[1:])) 490 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/tools/zip_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698