summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcclauss <cclauss@bluewin.ch>2018-12-03 12:28:31 +0100
committerAnna Henningsen <anna@addaleax.net>2018-12-06 10:30:04 +0100
commitb8fbe69db1292307adb2c2b2e0d5ef48c4ab2faf (patch)
tree67418cee83573e880655a12c197b5d14f0f19909
parentb1ada6c9def47a8ca90b0ea79419d3a704d1aa80 (diff)
downloadnode-new-b8fbe69db1292307adb2c2b2e0d5ef48c4ab2faf.tar.gz
tools: prepare tools/install.py for Python 3
PR-URL: https://github.com/nodejs/node/pull/24800 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
-rwxr-xr-xtools/install.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/tools/install.py b/tools/install.py
index af8e9e2708..659b3b23a9 100755
--- a/tools/install.py
+++ b/tools/install.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
+from __future__ import print_function
import ast
import errno
import os
@@ -25,11 +26,11 @@ def load_config():
def try_unlink(path):
try:
os.unlink(path)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.ENOENT: raise
def try_symlink(source_path, link_path):
- print 'symlinking %s -> %s' % (source_path, link_path)
+ print('symlinking %s -> %s' % (source_path, link_path))
try_unlink(link_path)
try_mkdir_r(os.path.dirname(link_path))
os.symlink(source_path, link_path)
@@ -37,7 +38,7 @@ def try_symlink(source_path, link_path):
def try_mkdir_r(path):
try:
os.makedirs(path)
- except OSError, e:
+ except OSError as e:
if e.errno != errno.EEXIST: raise
def try_rmdir_r(path):
@@ -45,7 +46,7 @@ def try_rmdir_r(path):
while path.startswith(install_path):
try:
os.rmdir(path)
- except OSError, e:
+ except OSError as e:
if e.errno == errno.ENOTEMPTY: return
if e.errno == errno.ENOENT: return
raise
@@ -60,14 +61,14 @@ def mkpaths(path, dst):
def try_copy(path, dst):
source_path, target_path = mkpaths(path, dst)
- print 'installing %s' % target_path
+ print('installing %s' % target_path)
try_mkdir_r(os.path.dirname(target_path))
try_unlink(target_path) # prevent ETXTBSY errors
return shutil.copy2(source_path, target_path)
def try_remove(path, dst):
source_path, target_path = mkpaths(path, dst)
- print 'removing %s' % target_path
+ print('removing %s' % target_path)
try_unlink(target_path)
try_rmdir_r(os.path.dirname(target_path))