mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-11-04 22:40:29 +03:00
always parse versions as strings, not bytes
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
This commit is contained in:
parent
20d082dfed
commit
7039d16046
3 changed files with 7 additions and 3 deletions
6
fdroid
6
fdroid
|
|
@ -76,9 +76,11 @@ def main():
|
|||
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.]+)["'].*''',
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ def get_clean_vm(reset=False):
|
|||
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:
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ def vagrant(params, cwd=None, printout=False):
|
|||
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue