mirror of
https://github.com/electron/node-gyp.git
synced 2025-08-15 12:58:19 +02:00
gyp: more decode stdout on Python 3
PR-URL: https://github.com/nodejs/node-gyp/pull/1894 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
This commit is contained in:
parent
d90d9c5426
commit
67dec1496a
2 changed files with 13 additions and 3 deletions
|
@ -8,13 +8,17 @@ import os
|
|||
import sys
|
||||
import subprocess
|
||||
|
||||
PY3 = bytes != str
|
||||
|
||||
# Below IsCygwin() function copied from pylib/gyp/common.py
|
||||
def IsCygwin():
|
||||
try:
|
||||
out = subprocess.Popen("uname",
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
stdout,stderr = out.communicate()
|
||||
stdout, stderr = out.communicate()
|
||||
if PY3:
|
||||
stdout = stdout.decode("utf-8")
|
||||
return "CYGWIN" in str(stdout)
|
||||
except Exception:
|
||||
return False
|
||||
|
@ -27,7 +31,9 @@ def UnixifyPath(path):
|
|||
out = subprocess.Popen(["cygpath", "-u", path],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
stdout,stderr = out.communicate()
|
||||
stdout, stderr = out.communicate()
|
||||
if PY3:
|
||||
stdout = stdout.decode("utf-8")
|
||||
return str(stdout)
|
||||
except Exception:
|
||||
return path
|
||||
|
|
|
@ -11,6 +11,8 @@ import tempfile
|
|||
import sys
|
||||
import subprocess
|
||||
|
||||
PY3 = bytes != str
|
||||
|
||||
|
||||
# A minimal memoizing decorator. It'll blow up if the args aren't immutable,
|
||||
# among other "problems".
|
||||
|
@ -623,7 +625,9 @@ def IsCygwin():
|
|||
out = subprocess.Popen("uname",
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT)
|
||||
stdout,stderr = out.communicate()
|
||||
stdout, stderr = out.communicate()
|
||||
if PY3:
|
||||
stdout = stdout.decode("utf-8")
|
||||
return "CYGWIN" in str(stdout)
|
||||
except Exception:
|
||||
return False
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue