validate:launcher: Reindent utils.py

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1121>
This commit is contained in:
Thibault Saunier 2021-10-12 18:05:52 -03:00 committed by GStreamer Marge Bot
parent 004a83f82a
commit 9a183e45d4

View file

@ -174,9 +174,9 @@ def printc(message, color="", title=False, title_char='', end="\n"):
global last_carriage_return_len global last_carriage_return_len
if title or title_char: if title or title_char:
length = 0 length = 0
for l in message.split("\n"): for line in message.split("\n"):
if len(l) > length: if len(line) > length:
length = len(l) length = len(line)
if length == 0: if length == 0:
length = len(message) length = len(message)
@ -319,9 +319,9 @@ def get_duration(media_file):
# in that case. # in that case.
pass pass
for l in res.split('\n'): for line in res.split('\n'):
if "Duration: " in l: if "Duration: " in line:
duration = parse_gsttimeargs(l.replace("Duration: ", "")) duration = parse_gsttimeargs(line.replace("Duration: ", ""))
break break
return duration return duration
@ -342,17 +342,17 @@ def get_gst_build_valgrind_suppressions():
return get_gst_build_valgrind_suppressions.data return get_gst_build_valgrind_suppressions.data
for suppression_path in ["gstreamer/tests/check/gstreamer.supp", for suppression_path in ["gstreamer/tests/check/gstreamer.supp",
"gst-plugins-base/tests/check/gst-plugins-base.supp", "gst-plugins-base/tests/check/gst-plugins-base.supp",
"gst-plugins-good/tests/check/gst-plugins-good.supp", "gst-plugins-good/tests/check/gst-plugins-good.supp",
"gst-plugins-bad/tests/check/gst-plugins-bad.supp", "gst-plugins-bad/tests/check/gst-plugins-bad.supp",
"gst-plugins-ugly/tests/check/gst-plugins-ugly.supp", "gst-plugins-ugly/tests/check/gst-plugins-ugly.supp",
"gst-libav/tests/check/gst-libav.supp", "gst-libav/tests/check/gst-libav.supp",
"gst-devtools/validate/data/gstvalidate.supp", "gst-devtools/validate/data/gstvalidate.supp",
"libnice/tests/libnice.supp", "libnice/tests/libnice.supp",
"libsoup/tests/libsoup.supp", "libsoup/tests/libsoup.supp",
"glib/glib.supp", "glib/glib.supp",
"gst-python/testsuite/gstpython.supp", "gst-python/testsuite/gstpython.supp",
"gst-python/testsuite/python.supp", "gst-python/testsuite/python.supp",
]: ]:
suppression = os.path.join(config.SRCDIR, "subprojects", suppression_path) suppression = os.path.join(config.SRCDIR, "subprojects", suppression_path)
if os.path.exists(suppression): if os.path.exists(suppression):
@ -429,7 +429,7 @@ class BackTraceGenerator(Loggable):
else: else:
newer_than = time.strftime("%a %Y-%m-%d %H:%M:%S %Z", time.localtime(test._starting_time)) newer_than = time.strftime("%a %Y-%m-%d %H:%M:%S %Z", time.localtime(test._starting_time))
coredumpctl = self.coredumpctl + ['info', os.path.basename(test.command[0]), coredumpctl = self.coredumpctl + ['info', os.path.basename(test.command[0]),
'--since', newer_than] '--since', newer_than]
try: try:
info = subprocess.check_output(coredumpctl, stderr=subprocess.STDOUT) info = subprocess.check_output(coredumpctl, stderr=subprocess.STDOUT)
@ -464,7 +464,7 @@ class BackTraceGenerator(Loggable):
try: try:
with tempfile.NamedTemporaryFile() as stderr: with tempfile.NamedTemporaryFile() as stderr:
coredump = subprocess.check_output(self.coredumpctl + ['dump', pid], coredump = subprocess.check_output(self.coredumpctl + ['dump', pid],
stderr=stderr) stderr=stderr)
with tempfile.NamedTemporaryFile() as tf: with tempfile.NamedTemporaryFile() as tf:
tf.write(coredump) tf.write(coredump)
@ -510,7 +510,7 @@ def check_bugs_resolution(bugs_definitions):
components = [c for c in url.path.split('/') if c] components = [c for c in url.path.split('/') if c]
if len(components) not in [4, 5]: if len(components) not in [4, 5]:
printc("\n + %s \n --> bug: %s\n --> Status: Not a proper gitlab report" % (regex, bug), printc("\n + %s \n --> bug: %s\n --> Status: Not a proper gitlab report" % (regex, bug),
Colors.WARNING) Colors.WARNING)
continue continue
project_id = components[0] + '%2F' + components[1] project_id = components[0] + '%2F' + components[1]
issue_id = int(components[-1]) issue_id = int(components[-1])
@ -659,7 +659,8 @@ def format_config_template(extra_data, config_text, test_name):
test_name.replace('.', os.sep)) test_name.replace('.', os.sep))
actual_results_dir = os.path.join(extra_vars['validate-flow-actual-results-dir'], actual_results_dir = os.path.join(extra_vars['validate-flow-actual-results-dir'],
test_name.replace('.', os.sep)) test_name.replace('.', os.sep))
extra_vars['validateflow'] = "validateflow, expectations-dir=\"%s\", actual-results-dir=\"%s\"" % (expectations_dir, actual_results_dir) extra_vars['validateflow'] = "validateflow, expectations-dir=\"%s\", actual-results-dir=\"%s\"" % (
expectations_dir, actual_results_dir)
if 'ssim-results-dir' in extra_vars: if 'ssim-results-dir' in extra_vars:
ssim_results = extra_vars['ssim-results-dir'] ssim_results = extra_vars['ssim-results-dir']
@ -681,6 +682,7 @@ def get_fakesink_for_media_type(media_type, needs_clock=False):
class InvalidValueError(ValueError): class InvalidValueError(ValueError):
"""Received value is invalid""" """Received value is invalid"""
def __init__(self, name, value, expect): def __init__(self, name, value, expect):
ValueError.__init__( ValueError.__init__(
self, "Invalid value {!r} for {}. Expect {}.".format( self, "Invalid value {!r} for {}. Expect {}.".format(
@ -940,9 +942,9 @@ class GstStructure(Loggable):
if type_is_unknown: if type_is_unknown:
self._check_unknown_typed_value(value) self._check_unknown_typed_value(value)
warning('GstStructure', warning('GstStructure',
"The GstStructure type {} with the value ({}) is " "The GstStructure type {} with the value ({}) is "
"unknown. The value will be stored and serialized as " "unknown. The value will be stored and serialized as "
"given.".format(_type, value)) "given.".format(_type, value))
_type = self._make_type_unknown(_type) _type = self._make_type_unknown(_type)
self.fields[key] = (_type, value) self.fields[key] = (_type, value)
@ -968,9 +970,9 @@ class GstStructure(Loggable):
value = self.get_value(key) value = self.get_value(key)
return value return value
warning('GstStructure', warning('GstStructure',
"The structure {} contains a value under {}, but is " "The structure {} contains a value under {}, but is "
"a {}, rather than the expected {} type".format( "a {}, rather than the expected {} type".format(
self.name, key, type_name, expect_type)) self.name, key, type_name, expect_type))
return default return default
def values(self): def values(self):
@ -1137,9 +1139,9 @@ class GstStructure(Loggable):
# prevent printing on subsequent calls if we find a # prevent printing on subsequent calls if we find a
# list within a list, etc. # list within a list, etc.
warning('GstStructure', warning('GstStructure',
"GstStructure received a range/list/array of type " "GstStructure received a range/list/array of type "
"{}, which can not be deserialized. Storing the " "{}, which can not be deserialized. Storing the "
"value as {}.".format(_type, value)) "value as {}.".format(_type, value))
else: else:
match = cls.FIELD_VALUE_REGEX.match(read) match = cls.FIELD_VALUE_REGEX.match(read)
if match is None: if match is None:
@ -1158,10 +1160,10 @@ class GstStructure(Loggable):
"({!s})".format(err)) "({!s})".format(err))
else: else:
warning('GstStructure', warning('GstStructure',
"GstStructure found a type {} that is unknown. " "GstStructure found a type {} that is unknown. "
"The corresponding value ({}) will not be " "The corresponding value ({}) will not be "
"deserialized and will be stored as given." "deserialized and will be stored as given."
"".format(_type, value)) "".format(_type, value))
if type_is_unknown and _type is not None: if type_is_unknown and _type is not None:
_type = cls._make_type_unknown(_type) _type = cls._make_type_unknown(_type)
return _type, value, read return _type, value, read
@ -1293,13 +1295,13 @@ class GstStructure(Loggable):
# see GST_ASCII_IS_STRING in gst_private.h # see GST_ASCII_IS_STRING in gst_private.h
GST_ASCII_CHARS = [ GST_ASCII_CHARS = [
ord(l) for l in "abcdefghijklmnopqrstuvwxyz" ord(line) for line in "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789" "0123456789"
"_-+/:." "_-+/:."
] ]
LEADING_OCTAL_CHARS = [ord(l) for l in "0123"] LEADING_OCTAL_CHARS = [ord(line) for line in "0123"]
OCTAL_CHARS = [ord(l) for l in "01234567"] OCTAL_CHARS = [ord(line) for line in "01234567"]
@classmethod @classmethod
def serialize_string(cls, value): def serialize_string(cls, value):
@ -1573,6 +1575,7 @@ class GstCapsFeatures():
""" """
Mimicking a GstCapsFeatures. Mimicking a GstCapsFeatures.
""" """
def __init__(self, *features): def __init__(self, *features):
""" """
Initialize the GstCapsFeatures. Initialize the GstCapsFeatures.