From abe17695bacee66298d94d1d70f842f0e2773d06 Mon Sep 17 00:00:00 2001 From: Daniel Schwarz Date: Tue, 18 Jun 2024 17:18:36 -0400 Subject: [PATCH] Added distribution info to toot diag (iff using Python 3.10+) --- toot/output.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/toot/output.py b/toot/output.py index 2b780e2..1b2f148 100644 --- a/toot/output.py +++ b/toot/output.py @@ -329,12 +329,14 @@ def print_diags(include_files: bool): import platform click.echo(f'{green(f"Platform:")} {platform.platform()}') -# Uncomment this when we move to minimum Python version 3.10 -# try: -# name = platform.freedesktop_os_release()['PRETTY_NAME'] -# click.echo(f'{green(f"Distro:")} {name}') -# except: # noqa -# pass + # print distro - only call if available (python 3.10+) + fd_os_release = getattr(platform, "freedesktop_os_release", None) # novermin + if callable(fd_os_release): # novermin + try: + name = platform.freedesktop_os_release()['PRETTY_NAME'] + click.echo(f'{green(f"Distro:")} {name}') + except: # noqa + pass click.echo(f'{green(f"Python version:")} {platform.python_version()}') click.echo(green("Dependency versions:"))