Backport function tests from centos stream
This commit is contained in:
parent
d37efc8796
commit
0ee1026718
@ -16,6 +16,8 @@
|
||||
|
||||
"""dmpd_library.py: Complete library providing functionality for device-mapper-persistent-data upstream test."""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import platform
|
||||
from os.path import expanduser
|
||||
import re #regex
|
||||
@ -25,7 +27,6 @@ import time
|
||||
import fileinput
|
||||
# TODO: Is this really necessary? Unlikely we will run into python2 in rawhide
|
||||
# again...
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
def _print(string):
|
||||
@ -55,7 +56,7 @@ def run(cmd, return_output=False, verbose=True, force_flush=False):
|
||||
date = "date \"+%Y-%m-%d %H:%M:%S\""
|
||||
p = subprocess.Popen(date, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
|
||||
stdout, stderr = p.communicate()
|
||||
stdout = stdout.rstrip("\n")
|
||||
stdout = stdout.decode('ascii', 'ignore').rstrip("\n")
|
||||
_print("INFO: [%s] Running: '%s'..." % (stdout, cmd))
|
||||
|
||||
#enabling shell=True, because was the only way I found to run command with '|'
|
||||
@ -77,7 +78,7 @@ def run(cmd, return_output=False, verbose=True, force_flush=False):
|
||||
|
||||
retcode = p.returncode
|
||||
|
||||
output = stdout + stderr
|
||||
output = stdout.decode('ascii', 'ignore') + stderr.decode('ascii', 'ignore')
|
||||
|
||||
#remove new line from last line
|
||||
output = output.rstrip()
|
||||
|
Loading…
Reference in New Issue
Block a user