diff options
author | smishin <smishin@yandex-team.ru> | 2022-02-10 16:51:05 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:51:05 +0300 |
commit | b416e76a260727c68d4301977966cfae384c2a23 (patch) | |
tree | 83bc374c2058d1ecb5e29f700fad8809984ef609 /library/python/testing/yatest_common/yatest/common/process.py | |
parent | c97fdc253119363a87ed8e30aa28fd08bfcdde35 (diff) | |
download | ydb-b416e76a260727c68d4301977966cfae384c2a23.tar.gz |
Restoring authorship annotation for <smishin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/python/testing/yatest_common/yatest/common/process.py')
-rw-r--r-- | library/python/testing/yatest_common/yatest/common/process.py | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/library/python/testing/yatest_common/yatest/common/process.py b/library/python/testing/yatest_common/yatest/common/process.py index a8bcc21f51..485eb26fa0 100644 --- a/library/python/testing/yatest_common/yatest/common/process.py +++ b/library/python/testing/yatest_common/yatest/common/process.py @@ -231,19 +231,19 @@ class _Execution(object): for key, value in six.iteritems(self._metrics): yatest_logger.debug("Command (pid %s) %s: %s", self._process.pid, key, value) - # Since this code is Python2/3 compatible, we don't know is _std_out/_std_err is real bytes or bytes-str. - printable_std_out, err = _try_convert_bytes_to_string(self._std_out) - if err: - yatest_logger.debug("Got error during parse process stdout: %s", err) - yatest_logger.debug("stdout will be displayed as raw bytes.") - printable_std_err, err = _try_convert_bytes_to_string(self._std_err) - if err: - yatest_logger.debug("Got error during parse process stderr: %s", err) - yatest_logger.debug("stderr will be displayed as raw bytes.") - - yatest_logger.debug("Command (pid %s) output:\n%s", self._process.pid, truncate(printable_std_out, MAX_OUT_LEN)) - yatest_logger.debug("Command (pid %s) errors:\n%s", self._process.pid, truncate(printable_std_err, MAX_OUT_LEN)) - + # Since this code is Python2/3 compatible, we don't know is _std_out/_std_err is real bytes or bytes-str. + printable_std_out, err = _try_convert_bytes_to_string(self._std_out) + if err: + yatest_logger.debug("Got error during parse process stdout: %s", err) + yatest_logger.debug("stdout will be displayed as raw bytes.") + printable_std_err, err = _try_convert_bytes_to_string(self._std_err) + if err: + yatest_logger.debug("Got error during parse process stderr: %s", err) + yatest_logger.debug("stderr will be displayed as raw bytes.") + + yatest_logger.debug("Command (pid %s) output:\n%s", self._process.pid, truncate(printable_std_out, MAX_OUT_LEN)) + yatest_logger.debug("Command (pid %s) errors:\n%s", self._process.pid, truncate(printable_std_err, MAX_OUT_LEN)) + def _clean_files(self): if self._err_file and not self._user_stderr and self._err_file != subprocess.PIPE: self._err_file.close() @@ -714,20 +714,20 @@ def backtrace_to_html(bt_filename, output): yatest_logger.debug("Failed to import coredump_filter: %s", e) with open(output, "wb") as afile: afile.write("<html>Failed to import coredump_filter in USE_ARCADIA_PYTHON=no mode</html>") - - -def _try_convert_bytes_to_string(source): - """ Function is necessary while this code Python2/3 compatible, because bytes in Python3 is a real bytes and in Python2 is not """ - # Bit ugly typecheck, because in Python2 isinstance(str(), bytes) and "type(str()) is bytes" working as True as well - if 'bytes' not in str(type(source)): - # We already got not bytes. Nothing to do here. - return source, False - - result = source - error = False - try: - result = source.decode(encoding='utf-8') - except ValueError as e: - error = e - - return result, error + + +def _try_convert_bytes_to_string(source): + """ Function is necessary while this code Python2/3 compatible, because bytes in Python3 is a real bytes and in Python2 is not """ + # Bit ugly typecheck, because in Python2 isinstance(str(), bytes) and "type(str()) is bytes" working as True as well + if 'bytes' not in str(type(source)): + # We already got not bytes. Nothing to do here. + return source, False + + result = source + error = False + try: + result = source.decode(encoding='utf-8') + except ValueError as e: + error = e + + return result, error |