validate:launcher: Try to dump logs with bat if avalaible

We got to many issues with mdv, it seems not to be maintained
bat is a very good replacement.
This commit is contained in:
Thibault Saunier 2019-08-12 16:56:41 -04:00 committed by Thibault Saunier
parent 06822b519b
commit e4ca67938e
2 changed files with 11 additions and 11 deletions

View file

@ -52,10 +52,6 @@ try:
except ImportError:
import xml.etree.cElementTree as ET
try:
import mdv
except ImportError:
mdv = None
from .vfb_server import get_virual_frame_buffer_server
from .httpserver import HTTPServer
@ -638,13 +634,16 @@ class Test(Loggable):
self.start_ts = time.time()
def _dump_log_file(self, logfile):
if which('bat'):
try:
subprocess.check_call(['bat', '-H', '1', '--paging=never', logfile])
return
except (subprocess.CalledProcessError, FileNotFoundError):
pass
with open(logfile, 'r') as fin:
printc(self.get_logfile_repr())
if mdv and utils.supports_ansi_colors():
printc(mdv.main(fin.read()))
else:
for line in fin.readlines():
print('> ' + line, end='')
for line in fin.readlines():
print('> ' + line, end='')
def _dump_log_files(self):
self._dump_log_file(self.logfile)

View file

@ -463,7 +463,8 @@ class LauncherConfig(Loggable):
parser.add_argument("--dump-on-failure", dest="dump_on_failure",
action="store_true", default=False,
help="Dump logs to stdout when a test fails."
" Note that mdv is used to enhance output if avalaible, install with `pip install mdv`.")
" Note that bat is used to enhance output if available"
" (See https://github.com/sharkdp/bat)")
parser.add_argument("--max-dump-size", dest="max_dump_size", type=float,
default=0.5, help="Maximum size of logs to dump on stdout in MB.")
parser.add_argument("-c", "--config", dest="config",