From 26337579293a9358759f87c9d663164cc695b956 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sun, 7 May 2023 12:36:52 +0200 Subject: [PATCH] Improve issue stdout --- .github/ISSUE_TEMPLATE.md | 13 ++++++++----- .github/ISSUE_TEMPLATE/bug_report.md | 6 +++++- glances/outputs/glances_stdout_issue.py | 20 ++++++++++++-------- 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index ebcfa8a9..a7b90112 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -10,10 +10,13 @@ For an enhancement or new feature: Describe your needs. #### Versions -* Glances & psutil (glances -V): -* Operating System (lsb_release -a): -* How do you install Glances (Pypi package, script, package manager, source): +* Glances & psutil (glances -V): `To be completed` +* Operating System (lsb_release -a): `To be completed` +* How do you install Glances (Pypi package, script, package manager, source): `To be completed` -#### Logs +#### Configuration and log file -You can also pastebin the Glances logs file (https://glances.readthedocs.io/en/latest/config.html#logging) +You can also [pastebin](https://pastebin.com/): + +* the Glances configuration file (https://glances.readthedocs.io/en/latest/config.html#location) +* the Glances log file (https://glances.readthedocs.io/en/latest/config.html#logging) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index e602208c..51f4c801 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -22,11 +22,15 @@ A clear and concise description of what you expected to happen. **Screenshots** If applicable, add screenshots to help explain your problem. -**Desktop (please complete the following information):** +**Environement (please complete the following information):** - OS: [e.g. GNU/Linux Ubuntu 20.04] - Glances Version [output of glances -V] - Glances logs file [output of tail -10 ] - Glances test [output of glances --issue] (only available with Glances 3.1.7 or higher) + ``` + Copy paste output of glances --issue here + ``` + **Additional context** Add any other context about the problem here. diff --git a/glances/outputs/glances_stdout_issue.py b/glances/outputs/glances_stdout_issue.py index 60ff04b9..4b960a48 100644 --- a/glances/outputs/glances_stdout_issue.py +++ b/glances/outputs/glances_stdout_issue.py @@ -12,8 +12,8 @@ import os import sys import platform -import shutil import time +import pprint from glances.timer import Counter from glances import __version__, psutil_version @@ -21,10 +21,7 @@ from glances import __version__, psutil_version import psutil import glances -try: - TERMINAL_WIDTH = shutil.get_terminal_size(fallback=(79, 24)).columns -except Exception: - TERMINAL_WIDTH = 79 +TERMINAL_WIDTH = 79 class colors: @@ -105,6 +102,10 @@ class GlancesStdoutIssue(object): stats._plugins[plugin].update() # Get the stats stat = stats.get_plugin(plugin).get_export() + # Hide private information + if plugin == 'ip': + for key in stat.keys(): + stat[key] = '***' except Exception as e: stat_error = e if stat_error is None: @@ -113,14 +114,17 @@ class GlancesStdoutIssue(object): ) if isinstance(stat, list) and len(stat) > 0 and 'key' in stat[0]: key = 'key={} '.format(stat[0]['key']) - message = colors.ORANGE + key + colors.NO + str(stat)[0 : TERMINAL_WIDTH - 41 - len(key)] + stat_output = pprint.pformat([stat[0]], compact=True, width=120, depth=3) + message = colors.ORANGE + key + colors.NO + '\n' + stat_output[0:-1] + ', ...' + stat_output[-1] else: - message = colors.NO + str(stat)[0 : TERMINAL_WIDTH - 41] + message = '\n' + colors.NO + pprint.pformat(stat, compact=True, width=120, depth=2) else: result = (colors.RED + '[ERROR]' + colors.BLUE + ' {:.5f}s '.format(counter.get())).rjust( 41 - len(plugin) ) - message = colors.NO + str(stat_error)[0 : TERMINAL_WIDTH - 41] + message = colors.NO + str(stat_error)[0: TERMINAL_WIDTH - 41] + + # Display the result self.print_issue(plugin, result, message) # Display total time need to update all plugins