Skip to content

Commit

Permalink
fix(diagnostics): OS name without further release files (#1703)
Browse files Browse the repository at this point in the history
Fix #1664
  • Loading branch information
buhtz committed Apr 27, 2024
1 parent b3b1a14 commit 2b23489
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
29 changes: 17 additions & 12 deletions common/backintime.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,14 @@ def createParsers(app_name = 'backintime'):
arg = '-%s' % alias
else:
arg = '--%s' % alias

group.add_argument(arg,
nargs = nargs,
action = PseudoAliasAction,
help = argparse.SUPPRESS)
nargs=nargs,
action=PseudoAliasAction,
help=argparse.SUPPRESS)


def startApp(app_name = 'backintime'):
def startApp(app_name='backintime'):
"""
Start the requested command or return config if there was no command
in arguments.
Expand All @@ -507,21 +509,22 @@ def startApp(app_name = 'backintime'):
args = argParse(None)

# Name, Version, As Root, OS
diag = collect_minimal_diagnostics()
logger.debug(
f'{diag["backintime"]} {list(diag["host-setup"]["OS"].values())}')
for key, val in collect_minimal_diagnostics().items():
logger.debug(f'{key}: {val}')

# Add source path to $PATH environ if running from source
if tools.runningFromSource():
tools.addSourceToPathEnviron()

# Warn about sudo
if tools.usingSudo() and os.getenv('BIT_SUDO_WARNING_PRINTED', 'false') == 'false':
if (tools.usingSudo()
and os.getenv('BIT_SUDO_WARNING_PRINTED', 'false') == 'false'):

os.putenv('BIT_SUDO_WARNING_PRINTED', 'true')
logger.warning("It looks like you're using 'sudo' to start %(app)s. "
"This will cause some trouble. Please use either 'sudo -i %(app_name)s' "
"or 'pkexec %(app_name)s'."
%{'app_name': app_name, 'app': config.Config.APP_NAME})
logger.warning(
"It looks like you're using 'sudo' to start "
f"{config.Config.APP_NAME}. This will cause some trouble. "
f"Please use either 'sudo -i {app_name}' or 'pkexec {app_name}'.")

# Call commands
if 'func' in dir(args):
Expand All @@ -530,8 +533,10 @@ def startApp(app_name = 'backintime'):
else:
setQuiet(args)
printHeader()

return getConfig(args, False)


def argParse(args):
"""
Parse arguments given on commandline.
Expand Down
7 changes: 7 additions & 0 deletions common/diagnostics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# SPDX-FileCopyrightText: © 2022 Christian BUHTZ <c.buhtz@posteo.jp>
#
# SPDX-License-Identifier: GPL-2.0
#
# This file is part of the program "Back In time" which is released under GNU
# General Public License v2 (GPLv2).
# See file LICENSE or go to <https://www.gnu.org/licenses/#GPL>.
"""Provides the ability to collect diagnostic information on Back In Time.
These are version numbers of the dependent tools, environment variables,
Expand Down

0 comments on commit 2b23489

Please sign in to comment.