Skip to content

Commit 039097e

Browse files
cclaussBethGriggs
cclauss
authored andcommitted
tools: prepare tools/install.py for Python 3
PR-URL: #24800 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
1 parent 552a5c0 commit 039097e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tools/install.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22

3+
from __future__ import print_function
34
import ast
45
import errno
56
import os
@@ -25,27 +26,27 @@ def load_config():
2526
def try_unlink(path):
2627
try:
2728
os.unlink(path)
28-
except OSError, e:
29+
except OSError as e:
2930
if e.errno != errno.ENOENT: raise
3031

3132
def try_symlink(source_path, link_path):
32-
print 'symlinking %s -> %s' % (source_path, link_path)
33+
print('symlinking %s -> %s' % (source_path, link_path))
3334
try_unlink(link_path)
3435
try_mkdir_r(os.path.dirname(link_path))
3536
os.symlink(source_path, link_path)
3637

3738
def try_mkdir_r(path):
3839
try:
3940
os.makedirs(path)
40-
except OSError, e:
41+
except OSError as e:
4142
if e.errno != errno.EEXIST: raise
4243

4344
def try_rmdir_r(path):
4445
path = abspath(path)
4546
while path.startswith(install_path):
4647
try:
4748
os.rmdir(path)
48-
except OSError, e:
49+
except OSError as e:
4950
if e.errno == errno.ENOTEMPTY: return
5051
if e.errno == errno.ENOENT: return
5152
raise
@@ -60,14 +61,14 @@ def mkpaths(path, dst):
6061

6162
def try_copy(path, dst):
6263
source_path, target_path = mkpaths(path, dst)
63-
print 'installing %s' % target_path
64+
print('installing %s' % target_path)
6465
try_mkdir_r(os.path.dirname(target_path))
6566
try_unlink(target_path) # prevent ETXTBSY errors
6667
return shutil.copy2(source_path, target_path)
6768

6869
def try_remove(path, dst):
6970
source_path, target_path = mkpaths(path, dst)
70-
print 'removing %s' % target_path
71+
print('removing %s' % target_path)
7172
try_unlink(target_path)
7273
try_rmdir_r(os.path.dirname(target_path))
7374

0 commit comments

Comments
 (0)