diff options
author | Alexander Pyhalov <apyhalov@gmail.com> | 2019-08-07 23:02:25 +0300 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2019-08-15 15:45:12 +0000 |
commit | fe949611d4f0a0f42a6923a31cd3073e5b2bc97c (patch) | |
tree | 409be862b0346084b51b1ba60c3b4bfb8952ce7a | |
parent | c1064fd7ce62fe763a4475e9988ffea3b22137de (diff) | |
download | illumos-joyent-fe949611d4f0a0f42a6923a31cd3073e5b2bc97c.tar.gz |
10540 wsdiff much slower under python3 than python2
Reviewed by: Andy Fiddaman <omnios@citrus-it.co.uk>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
Approved by: Robert Mustacchi <rm@joyent.com>
-rw-r--r-- | usr/src/tools/scripts/wsdiff.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/usr/src/tools/scripts/wsdiff.py b/usr/src/tools/scripts/wsdiff.py index aaab371708..225ea21ce5 100644 --- a/usr/src/tools/scripts/wsdiff.py +++ b/usr/src/tools/scripts/wsdiff.py @@ -119,11 +119,21 @@ wsdiff_exceptions = [ "usr/perl5/5.6.1/lib/i86pc-solaris-64int/CORE/libperl.so.1" ] -def getoutput(cmd): - if PY3: - return subprocess.getstatusoutput(cmd) - else: - return commands.getstatusoutput(cmd) +if PY3: + def getoutput(cmd): + import shlex, tempfile + f, fpath = tempfile.mkstemp() + status = os.system("{ " + cmd + "; } >" + + shlex.quote(fpath) + " 2>&1") + returncode = os.WEXITSTATUS(status) + with os.fdopen(f, "r") as tfile: + output = tfile.read() + os.unlink(fpath) + if output[-1:] == '\n': + output = output[:-1] + return returncode, output +else: + getoutput = commands.getstatusoutput ##### # Logging routines |