ensure output format of 'subprocess.check_output' is same in Python2/3

Once upgraded to CentOS 8, the default python env (both of runtime and
build container) is python3. 
It fails to build platform-kickstart rpm for the changes of function
'subprocess.check_output' during upgrading from python2 to python3.

In python3.5 or above the default output format of function
'subprocess.check_output', which is str in python2, is bytes. However if
factor 'universal_newlines' is set as True, the output format will be
str in both python3 and python2.

Setting "universal_newlines=True" is safe for current system and can
solve issues met in python3. 

Change-Id: I01b166b5669553d9363b745747e1e9901345904f
Story: 2007018
Task: 37803
Signed-off-by: SidneyAn <ran1.an@intel.com>
This commit is contained in:
SidneyAn 2019-12-13 16:54:03 +08:00 committed by Ran An
parent c4b8171ddd
commit cdabacd300
1 changed files with 3 additions and 1 deletions

View File

@ -118,7 +118,9 @@ def main():
# Get the pkglist
cmd = "sed 's/#.*//' %s" % ' '.join(pkglist)
rpmlist = subprocess.check_output(cmd, shell=True).split()
rpmlist = subprocess.check_output(cmd,
shell=True,
universal_newlines=True).split()
tree = ElementTree.parse(groups_file)
comps = tree.getroot()