Skip to content

Commit 039097e

Browse files
cclaussBethGriggs
authored andcommitted
tools: prepare tools/install.py for Python 3
PR-URL: #24800 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent 552a5c0 commit 039097e

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

‎tools/install.py‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env python
22

3+
from __future__ importprint_function
34
importast
45
importerrno
56
importos
@@ -25,27 +26,27 @@ def load_config():
2526
deftry_unlink(path):
2627
try:
2728
os.unlink(path)
28-
exceptOSError,e:
29+
exceptOSErrorase:
2930
ife.errno!=errno.ENOENT: raise
3031

3132
deftry_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
deftry_mkdir_r(path):
3839
try:
3940
os.makedirs(path)
40-
exceptOSError,e:
41+
exceptOSErrorase:
4142
ife.errno!=errno.EEXIST: raise
4243

4344
deftry_rmdir_r(path):
4445
path=abspath(path)
4546
whilepath.startswith(install_path):
4647
try:
4748
os.rmdir(path)
48-
exceptOSError,e:
49+
exceptOSErrorase:
4950
ife.errno==errno.ENOTEMPTY: return
5051
ife.errno==errno.ENOENT: return
5152
raise
@@ -60,14 +61,14 @@ def mkpaths(path, dst):
6061

6162
deftry_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
returnshutil.copy2(source_path, target_path)
6768

6869
deftry_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)