Skip to content

Commit 4cb0061

Browse files
committed
[tools] update package_binaries.py to python3
1 parent b67f893 commit 4cb0061

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

tools/package_binaries.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@
5555
binaries_location = os.path.join(os.getcwd(), binaries_location)
5656

5757
if not os.path.isdir(binaries_location):
58-
print 'Invalid path: ' + binaries_location
58+
print ('Invalid path: ' + binaries_location)
5959
exit(-1)
6060
binaries_location = os.path.normpath(binaries_location)
6161
dist_dir = os.path.join(binaries_location, 'dist')
6262

63-
print 'Working on ' + binaries_location
63+
print ('Working on ' + binaries_location)
6464

6565
nwfolder = os.path.join(dist_dir, '..', 'nwdist')
6666
try:
@@ -80,7 +80,7 @@
8080
elif sys.platform == 'darwin':
8181
platform_name = 'osx'
8282
else:
83-
print 'Unsupported platform: ' + sys.platform
83+
print ('Unsupported platform: ' + sys.platform)
8484
exit(-1)
8585

8686
_arch = platform.architecture()[0]
@@ -89,7 +89,7 @@
8989
elif _arch == '32bit':
9090
arch = 'ia32'
9191
else:
92-
print 'Unsupported arch: ' + _arch
92+
print ('Unsupported arch: ' + _arch)
9393
exit(-1)
9494

9595
if platform_name == 'win':
@@ -222,7 +222,7 @@ def generate_target_nw(platform_name, arch, version):
222222
target['input'].append('minidump_stackwalk')
223223
target['input'].append('v8_context_snapshot.x86_64.bin')
224224
else:
225-
print 'Unsupported platform: ' + platform_name
225+
print ('Unsupported platform: ' + platform_name)
226226
exit(-1)
227227
return target
228228

@@ -282,7 +282,7 @@ def generate_target_symbols(platform_name, arch, version):
282282
]
283283
target['folder'] = True
284284
else:
285-
print 'Unsupported platform: ' + platform_name
285+
print ('Unsupported platform: ' + platform_name)
286286
exit(-1)
287287
return target
288288

@@ -296,10 +296,10 @@ def generate_target_headers(platform_name, arch, version):
296296
# here , call make-nw-headers.py to generate nw headers
297297
make_nw_header = os.path.join(os.path.dirname(__file__), \
298298
'make-nw-headers.py')
299-
print make_nw_header
299+
print (make_nw_header)
300300
res = call(['python', make_nw_header, '-p', binaries_location, '-n', platform_name])
301301
if res == 0:
302-
print 'nw-headers generated'
302+
print ('nw-headers generated')
303303
nw_headers_name = 'nw-headers-v' + version + '.tar.gz'
304304
nw_headers_path = os.path.join(os.path.dirname(__file__), \
305305
os.pardir, 'tmp', nw_headers_name)
@@ -315,7 +315,7 @@ def generate_target_headers(platform_name, arch, version):
315315
target['input'].append('SHASUMS256.txt')
316316
else:
317317
#TODO, handle err
318-
print 'nw-headers generate failed'
318+
print ('nw-headers generate failed')
319319
return target
320320

321321
def generate_target_empty(platform_name, arch, version):
@@ -372,7 +372,7 @@ def _ArchiveDirectory(parentDirectory):
372372
zipInfo.create_system = 3
373373
# long type of hex val of '0xA1ED0000L',
374374
# say, symlink attr magic...
375-
zipInfo.external_attr = 2716663808L
375+
zipInfo.external_attr = 2716663808
376376
zipOut.writestr(zipInfo, os.readlink(fullPath))
377377
else:
378378
zipOut.write(fullPath, archiveRoot, zipfile.ZIP_DEFLATED)
@@ -394,21 +394,21 @@ def compress(from_dir, to_dir, fname, compress):
394394
z.close()
395395
elif compress == 'tar.gz': # only for folders
396396
if not os.path.isdir(_from):
397-
print 'Will not create tar.gz for a single file: ' + _from
397+
print ('Will not create tar.gz for a single file: ' + _from)
398398
exit(-1)
399399
with tarfile.open(_to + '.tar.gz', 'w:gz') as tar:
400400
tar.add(_from, arcname=os.path.basename(_from))
401401
elif compress == 'gz': # only for single file
402402
if os.path.isdir(_from):
403-
print 'Will not create gz for a folder: ' + _from
403+
print ('Will not create gz for a folder: ' + _from)
404404
exit(-1)
405405
f_in = open(_from, 'rb')
406406
f_out = gzip.open(_to + '.gz', 'wb')
407407
f_out.writelines(f_in)
408408
f_out.close()
409409
f_in.close()
410410
else:
411-
print 'Unsupported compression format: ' + compress
411+
print ('Unsupported compression format: ' + compress)
412412
exit(-1)
413413

414414

@@ -418,13 +418,13 @@ def make_packages(targets):
418418
for f in t['input']:
419419
src = os.path.join(binaries_location, f)
420420
if not os.path.exists(src):
421-
print 'File does not exist: ', src
421+
print ('File does not exist: ', src)
422422
exit(-1)
423423

424424
# clear the output folder
425425
if os.path.exists(dist_dir):
426426
if not os.path.isdir(dist_dir):
427-
print 'Invalid path: ' + dist_dir
427+
print ('Invalid path: ' + dist_dir)
428428
exit(-1)
429429
else:
430430
shutil.rmtree(dist_dir)
@@ -441,10 +441,10 @@ def make_packages(targets):
441441
dest = os.path.join(dist_dir, t['output'])
442442
else:
443443
dest = os.path.join(dist_dir, f)
444-
print "Copying " + f
444+
print ("Copying " + f)
445445
shutil.copy(src, dest)
446-
elif (t.has_key('folder') and t['folder'] == True) or len(t['input']) > 1:
447-
print 'Making "' + t['output'] + '.' + t['compress'] + '"'
446+
elif ('folder' in t and t['folder'] == True) or len(t['input']) > 1:
447+
print ('Making "' + t['output'] + '.' + t['compress'] + '"')
448448
# copy files into a folder then pack
449449
folder = os.path.join(dist_dir, t['output'])
450450
os.mkdir(folder)
@@ -461,13 +461,13 @@ def make_packages(targets):
461461
shutil.copy(src, dest)
462462
compress(dist_dir, dist_dir, t['output'], t['compress'])
463463
# remove temp folders
464-
if (t.has_key('keep4test')) :
464+
if ('keep4test' in t) :
465465
shutil.copytree(folder, nwfolder, symlinks=True)
466466

467467
shutil.rmtree(folder)
468468
else:
469469
# single file
470-
print 'Making "' + t['output'] + '.' + t['compress'] + '"'
470+
print ('Making "' + t['output'] + '.' + t['compress'] + '"')
471471
compress(binaries_location, dist_dir, t['input'][0], t['compress'])
472472

473473
# must be aligned with steps
@@ -487,7 +487,7 @@ def make_packages(targets):
487487
continue
488488
targets.append(generators[s](platform_name, arch, nw_ver))
489489

490-
print 'Creating packages...'
490+
print ('Creating packages...')
491491
make_packages(targets)
492492

493493
# vim: et:ts=4:sw=4

0 commit comments

Comments
 (0)