Fixes a couple errors like:
File "./makebuildserver", line 30, in vagrant
out += line
TypeError: Can't convert 'bytes' object to str implicitly
If universal_newlines=False, the default, then Popen will return bytes if
the newlines in the data do not match the system's newlines. Setting it to
true enables auto-conversion, and then guarantees that the data is always
str.
"If universal_newlines is True, the file objects stdin, stdout and stderr
are opened as text streams in universal newlines mode, as described above
in Frequently Used Arguments, otherwise they are opened as binary streams."
https://docs.python.org/3/library/subprocess.html#subprocess.Popen
import subprocess
try:
output = subprocess.check_output(['git', 'describe'],
- stderr=subprocess.STDOUT)
+ stderr=subprocess.STDOUT,
+ universal_newlines=True)
except subprocess.CalledProcessError:
- output = 'git commit ' + subprocess.check_output(['git', 'rev-parse', 'HEAD'])
+ output = 'git commit ' + subprocess.check_output(['git', 'rev-parse', 'HEAD'],
+ universal_newlines=True)
elif os.path.exists('setup.py'):
import re
m = re.search(r'''.*[\s,\(]+version\s*=\s*["']([0-9a-z.]+)["'].*''',
os.mkdir('builder')
p = subprocess.Popen(['vagrant', '--version'],
+ universal_newlines=True,
stdout=subprocess.PIPE)
vver = p.communicate()[0].strip().split(' ')[1]
if vver.split('.')[0] != '1' or int(vver.split('.')[1]) < 4:
is the stdout (and stderr) from vagrant
"""
p = subprocess.Popen(['vagrant'] + params, cwd=cwd,
- stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ universal_newlines=True)
out = ''
if printout:
while True: