From fe949611d4f0a0f42a6923a31cd3073e5b2bc97c Mon Sep 17 00:00:00 2001 From: Alexander Pyhalov Date: Wed, 7 Aug 2019 23:02:25 +0300 Subject: 10540 wsdiff much slower under python3 than python2 Reviewed by: Andy Fiddaman Reviewed by: Richard Lowe Approved by: Robert Mustacchi --- usr/src/tools/scripts/wsdiff.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'usr/src/tools/scripts/wsdiff.py') 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 -- cgit v1.2.3