logview: 2to3 it and make sure it is using python3.8
Signed-off-by: Kevin Fenzi <kevin@scrye.com>
This commit is contained in:
parent
f7490bfd81
commit
c679788f00
1 changed files with 10 additions and 10 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python3.8
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: et ts=4 ai sw=4 sts=0
|
# vim: et ts=4 ai sw=4 sts=0
|
||||||
import sys
|
import sys
|
||||||
|
@ -15,7 +15,7 @@ try:
|
||||||
import configparser
|
import configparser
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Python2
|
# Python2
|
||||||
import ConfigParser as configparser
|
import configparser as configparser
|
||||||
from ansible.config.manager import find_ini_config_file
|
from ansible.config.manager import find_ini_config_file
|
||||||
from ansible.utils.color import stringc
|
from ansible.utils.color import stringc
|
||||||
from ansible import constants as C
|
from ansible import constants as C
|
||||||
|
@ -51,7 +51,7 @@ def colorByCat(category, txt=None):
|
||||||
color_out = stringc(txt, C.COLOR_UNREACHABLE)
|
color_out = stringc(txt, C.COLOR_UNREACHABLE)
|
||||||
else:
|
else:
|
||||||
# This hack make sure the text width is the same as any other colored text
|
# 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:
|
if not HAS_COLOR:
|
||||||
color_out = txt
|
color_out = txt
|
||||||
return color_out
|
return color_out
|
||||||
|
@ -102,7 +102,7 @@ def format_stats(stats):
|
||||||
def col_width(rows):
|
def col_width(rows):
|
||||||
widths = []
|
widths = []
|
||||||
for col in zip(*(rows)):
|
for col in zip(*(rows)):
|
||||||
col_width = max(map(len, col))
|
col_width = max(list(map(len, col)))
|
||||||
widths.append(col_width)
|
widths.append(col_width)
|
||||||
widths[-1] = 0 # don't pad last column
|
widths[-1] = 0 # don't pad last column
|
||||||
return widths
|
return widths
|
||||||
|
@ -115,12 +115,12 @@ def date_cheat(datestr):
|
||||||
|
|
||||||
def date_from_path(path):
|
def date_from_path(path):
|
||||||
date_comp = re.search(r'/(\d{4})/(\d{2})/(\d{2})', 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):
|
def datetime_from_path(path):
|
||||||
date_comp = re.search(r'/(\d{4})/(\d{2})/(\d{2})/(\d{2})\.(\d{2})\.(\d{2})', 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):
|
def parse_args(args):
|
||||||
|
@ -279,7 +279,7 @@ def main(args):
|
||||||
stats = Counter()
|
stats = Counter()
|
||||||
hosts = []
|
hosts = []
|
||||||
if "stats" in pb:
|
if "stats" in pb:
|
||||||
for host, stat in pb['stats'].items():
|
for host, stat in list(pb['stats'].items()):
|
||||||
del stat['task_userid']
|
del stat['task_userid']
|
||||||
stats += Counter(stat)
|
stats += Counter(stat)
|
||||||
hosts.append(host)
|
hosts.append(host)
|
||||||
|
@ -295,7 +295,7 @@ def main(args):
|
||||||
print("no log")
|
print("no log")
|
||||||
else:
|
else:
|
||||||
for row in rows:
|
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
|
# Play detail
|
||||||
else:
|
else:
|
||||||
|
@ -316,9 +316,9 @@ def main(args):
|
||||||
rows = search_logs(opts, logfiles)
|
rows = search_logs(opts, logfiles)
|
||||||
if len(rows) > 1:
|
if len(rows) > 1:
|
||||||
m_widths = col_width(rows)
|
m_widths = col_width(rows)
|
||||||
print("%s\n-------" % (pb_name,))
|
print(("%s\n-------" % (pb_name,)))
|
||||||
for row in rows:
|
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("")
|
print("")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue