mirror of
https://github.com/ihabunek/toot.git
synced 2024-09-29 04:35:54 -04:00
Added 'toot diag' command that outputs useful diagnostic info
This commit is contained in:
parent
31501a84a0
commit
ee45ec1ffd
2
.flake8
2
.flake8
@ -1,4 +1,4 @@
|
|||||||
[flake8]
|
[flake8]
|
||||||
exclude=build,tests,tmp,venv,toot/tui/scroll.py
|
exclude=build,tests,tmp,venv,_env,toot/tui/scroll.py
|
||||||
ignore=E128,W503,W504
|
ignore=E128,W503,W504
|
||||||
max-line-length=120
|
max-line-length=120
|
||||||
|
@ -173,6 +173,7 @@ def cli(ctx: click.Context, max_width: int, color: bool, debug: bool, as_user: s
|
|||||||
|
|
||||||
from toot.cli import accounts # noqa
|
from toot.cli import accounts # noqa
|
||||||
from toot.cli import auth # noqa
|
from toot.cli import auth # noqa
|
||||||
|
from toot.cli import diag # noqa
|
||||||
from toot.cli import lists # noqa
|
from toot.cli import lists # noqa
|
||||||
from toot.cli import post # noqa
|
from toot.cli import post # noqa
|
||||||
from toot.cli import read # noqa
|
from toot.cli import read # noqa
|
||||||
|
14
toot/cli/diag.py
Normal file
14
toot/cli/diag.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
from toot.output import print_diags
|
||||||
|
from toot.cli import (
|
||||||
|
cli,
|
||||||
|
pass_context,
|
||||||
|
Context,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@cli.command()
|
||||||
|
@pass_context
|
||||||
|
def diag(ctx: Context):
|
||||||
|
"""Display useful information for diagnosing problems"""
|
||||||
|
|
||||||
|
print_diags()
|
@ -314,6 +314,41 @@ def format_account_name(account: Account) -> str:
|
|||||||
return acct
|
return acct
|
||||||
|
|
||||||
|
|
||||||
|
def print_diags():
|
||||||
|
from importlib.metadata import version
|
||||||
|
|
||||||
|
click.echo(f'{green(f"Diagnostic Information")}')
|
||||||
|
from datetime import datetime, timezone
|
||||||
|
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
|
click.echo(f'{green("Current Date/Time:")} {now.strftime("%Y-%m-%d %H:%M:%S %Z")}')
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
click.echo(f'{green(f"Python version:")} {platform.python_version()}')
|
||||||
|
click.echo(green("Dependency versions:"))
|
||||||
|
|
||||||
|
deps = ['beautifulsoup4', 'click', 'requests', 'tomlkit', 'urwid', 'wcwidth',
|
||||||
|
'pillow', 'term-image', 'urwidgets', 'flake8', 'pytest', 'setuptools',
|
||||||
|
'vermin', 'typing-extensions']
|
||||||
|
|
||||||
|
for dep in deps:
|
||||||
|
try:
|
||||||
|
ver = version(dep)
|
||||||
|
except: # noqa
|
||||||
|
ver = yellow("not installed")
|
||||||
|
|
||||||
|
click.echo(f"\t{dep}: {ver}")
|
||||||
|
|
||||||
|
|
||||||
# Shorthand functions for coloring output
|
# Shorthand functions for coloring output
|
||||||
|
|
||||||
def blue(text: t.Any) -> str:
|
def blue(text: t.Any) -> str:
|
||||||
|
Loading…
Reference in New Issue
Block a user