diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-15 17:46:21 +0100 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-15 17:46:21 +0100 |
commit | a8c9e878d5b43cbb729187ae6e1304eebd09b8dc (patch) | |
tree | 578fcbc89480db76a0828de2d9d2d78f273a02f6 /scripts/internal/print_access_denied.py | |
parent | a826d41cd880d4aea907f68351c4bc1414d2575c (diff) | |
download | psutil-a8c9e878d5b43cbb729187ae6e1304eebd09b8dc.tar.gz |
refactor print colors utils
Diffstat (limited to 'scripts/internal/print_access_denied.py')
-rw-r--r-- | scripts/internal/print_access_denied.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/scripts/internal/print_access_denied.py b/scripts/internal/print_access_denied.py index 2c757fd7..9123ba6d 100644 --- a/scripts/internal/print_access_denied.py +++ b/scripts/internal/print_access_denied.py @@ -50,7 +50,7 @@ from collections import defaultdict import time import psutil -from scriptutils import hilite +from psutil._common import print_color def main(): @@ -75,13 +75,12 @@ def main(): # print templ = "%-20s %-5s %-9s %s" s = templ % ("API", "AD", "Percent", "Outcome") - print(hilite(s, ok=None, bold=True)) + print_color(s, color=None, bold=True) for methname, ads in sorted(d.items(), key=lambda x: (x[1], x[0])): perc = (ads / tot_procs) * 100 outcome = "SUCCESS" if not ads else "ACCESS DENIED" s = templ % (methname, ads, "%6.1f%%" % perc, outcome) - s = hilite(s, ok=not ads) - print(s) + print_color(s, "red" if ads else None) tot_perc = round((tot_ads / tot_calls) * 100, 1) print("-" * 50) print("Totals: access-denied=%s (%s%%), calls=%s, processes=%s, " |