use subprocess.run(..., text=True) instead of stdout.decode()

This commit is contained in:
Martin Liska 2023-01-12 16:46:19 +01:00
parent 37cdd05cf5
commit c2c525c35f
3 changed files with 6 additions and 5 deletions

View File

@ -94,7 +94,7 @@ class MenuCheck(AbstractCheck):
directory = pkg.dir_name()
for f in menus:
# remove comments and handle cpp continuation lines
text = subprocess.run(('/lib/cpp', directory + f), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=ENGLISH_ENVIROMENT).stdout.decode()
text = subprocess.run(('/lib/cpp', directory + f), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=ENGLISH_ENVIROMENT, text=True).stdout
if text.endswith('\n'):
text = text[:-1]

View File

@ -44,8 +44,9 @@ class MenuXDGCheck(AbstractFilesCheck):
root = pkg.dir_name()
f = root + filename
try:
command = subprocess.run(('desktop-file-validate', f), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, env=ENGLISH_ENVIROMENT)
text = command.stdout.decode()
command = subprocess.run(('desktop-file-validate', f), stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
env=ENGLISH_ENVIROMENT, text=True)
text = command.stdout
if command.returncode:
error_printed = False
for line in text.splitlines():

View File

@ -489,8 +489,8 @@ class Pkg(AbstractPkg):
def check_signature(self):
ret = subprocess.run(('rpm', '-Kv', self.filename),
stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
env=ENGLISH_ENVIROMENT)
text = ret.stdout.decode()
env=ENGLISH_ENVIROMENT, text=True)
text = ret.stdout
if text.endswith('\n'):
text = text[:-1]
return ret.returncode, text