Files
OctoPrint/src/octoprint/cli/systeminfo.py
T
Gina Häußge a58e02940d ✨ New system info collection, ready for copy/paste
Should hopefully make it easier in the future to collect data needed
for ticket processing. Can be accessed through System Information in the
About dialog (also directly linked from the footer and the settings),
via a new sub command `octoprint systeminfo` on the command
line and on the recovery page.

Currently included:

  * octoprint version
  * safe mode yes/no
  * printer firmware name (if connected)
  * browser user agent (if dump happens through API)
  * everything reported by the environment detector (that includes data
    from plugins as well that add to that, e.g. pi_support)
  * connectivity check information

Might be extended more in the future.
2020-11-02 18:24:59 +01:00

73 lines
2.1 KiB
Python

# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
__license__ = "GNU Affero General Public License http://www.gnu.org/licenses/agpl.html"
__copyright__ = "Copyright (C) 2015 The OctoPrint Project - Released under terms of the AGPLv3 License"
import logging
import click
from octoprint.cli import get_ctx_obj_option, standard_options
click.disable_unicode_literals_warning = True
def get_systeminfo(environment_detector, connectivity_checker):
from octoprint import __version__
from octoprint.util import dict_flatten
environment_detector.run_detection(notify_plugins=False)
systeminfo = {
"octoprint": {"version": __version__},
"connectivity": connectivity_checker.as_dict(),
"env": environment_detector.environment,
}
# flatten and filter
flattened = dict_flatten(systeminfo)
flattened["env.python.virtualenv"] = "env.python.virtualenv" in flattened
return flattened
@click.group()
def systeminfo_commands():
pass
@systeminfo_commands.command(name="systeminfo")
@standard_options()
@click.pass_context
def systeminfo_command(ctx, **kwargs):
"""Retrieves and prints the system info."""
from octoprint import FatalStartupError, init_platform
logging.disable(logging.ERROR)
try:
components = init_platform(
get_ctx_obj_option(ctx, "basedir", None),
get_ctx_obj_option(ctx, "configfile", None),
safe_mode=True,
)
except FatalStartupError as e:
click.echo(str(e), err=True)
click.echo("There was a fatal error initializing the settings manager.", err=True)
ctx.exit(-1)
else:
(
settings,
logger,
safe_mode,
event_manager,
connectivity_checker,
plugin_manager,
environment_detector,
) = components
systeminfo = get_systeminfo(environment_detector, connectivity_checker)
for k in sorted(systeminfo.keys()):
click.echo("{}: {}".format(k, systeminfo[k]))