logview: 2to3 it and make sure it is using python3.8

Signed-off-by: Kevin Fenzi <kevin@scrye.com>
This commit is contained in:
Kevin Fenzi 2022-05-23 13:04:17 -07:00
parent f7490bfd81
commit c679788f00

View file

@ -1,4 +1,4 @@
#!/usr/bin/python
#!/usr/bin/python3.8
# -*- coding: utf-8 -*-
# vim: et ts=4 ai sw=4 sts=0
import sys
@ -15,7 +15,7 @@ try:
import configparser
except ImportError:
# Python2
import ConfigParser as configparser
import configparser as configparser
from ansible.config.manager import find_ini_config_file
from ansible.utils.color import stringc
from ansible import constants as C
@ -51,7 +51,7 @@ def colorByCat(category, txt=None):
color_out = stringc(txt, C.COLOR_UNREACHABLE)
else:
# This hack make sure the text width is the same as any other colored text
color_out = u'\x1b[0;00m%s\x1b[0m' % (txt,)
color_out = '\x1b[0;00m%s\x1b[0m' % (txt,)
if not HAS_COLOR:
color_out = txt
return color_out
@ -102,7 +102,7 @@ def format_stats(stats):
def col_width(rows):
widths = []
for col in zip(*(rows)):
col_width = max(map(len, col))
col_width = max(list(map(len, col)))
widths.append(col_width)
widths[-1] = 0 # don't pad last column
return widths
@ -115,12 +115,12 @@ def date_cheat(datestr):
def date_from_path(path):
date_comp = re.search(r'/(\d{4})/(\d{2})/(\d{2})', path)
return datetime(*map(int, date_comp.groups()))
return datetime(*list(map(int, date_comp.groups())))
def datetime_from_path(path):
date_comp = re.search(r'/(\d{4})/(\d{2})/(\d{2})/(\d{2})\.(\d{2})\.(\d{2})', path)
return datetime(*map(int, date_comp.groups()))
return datetime(*list(map(int, date_comp.groups())))
def parse_args(args):
@ -279,7 +279,7 @@ def main(args):
stats = Counter()
hosts = []
if "stats" in pb:
for host, stat in pb['stats'].items():
for host, stat in list(pb['stats'].items()):
del stat['task_userid']
stats += Counter(stat)
hosts.append(host)
@ -295,7 +295,7 @@ def main(args):
print("no log")
else:
for row in rows:
print(" ".join((val.ljust(width) for val, width in zip(row, m_widths))).strip())
print((" ".join((val.ljust(width) for val, width in zip(row, m_widths))).strip()))
# Play detail
else:
@ -316,9 +316,9 @@ def main(args):
rows = search_logs(opts, logfiles)
if len(rows) > 1:
m_widths = col_width(rows)
print("%s\n-------" % (pb_name,))
print(("%s\n-------" % (pb_name,)))
for row in rows:
print(" ".join((val.ljust(width) for val, width in zip(row, m_widths))))
print((" ".join((val.ljust(width) for val, width in zip(row, m_widths)))))
print("")