mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
🎨 Format Python code with Black
This commit is contained in:
parent
7121ed6836
commit
fbe42f1867
2 changed files with 21 additions and 9 deletions
|
@ -2328,8 +2328,10 @@ def backup_restore(name, system=[], apps=[], force=False):
|
||||||
# Add validation if restoring system parts on an already-installed system
|
# Add validation if restoring system parts on an already-installed system
|
||||||
#
|
#
|
||||||
|
|
||||||
if restore_manager.info["system"] != {} and restore_manager.targets.targets["system"] != [] and os.path.isfile(
|
if (
|
||||||
"/etc/yunohost/installed"
|
restore_manager.info["system"] != {}
|
||||||
|
and restore_manager.targets.targets["system"] != []
|
||||||
|
and os.path.isfile("/etc/yunohost/installed")
|
||||||
):
|
):
|
||||||
logger.warning(m18n.n("yunohost_already_installed"))
|
logger.warning(m18n.n("yunohost_already_installed"))
|
||||||
if not force:
|
if not force:
|
||||||
|
|
|
@ -252,7 +252,11 @@ def aptitude_with_progress_bar(cmd):
|
||||||
|
|
||||||
if package == "dpkg-exec":
|
if package == "dpkg-exec":
|
||||||
return
|
return
|
||||||
if package and log_apt_status_to_progress_bar.previous_package and package == log_apt_status_to_progress_bar.previous_package:
|
if (
|
||||||
|
package
|
||||||
|
and log_apt_status_to_progress_bar.previous_package
|
||||||
|
and package == log_apt_status_to_progress_bar.previous_package
|
||||||
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -276,18 +280,22 @@ def aptitude_with_progress_bar(cmd):
|
||||||
log_apt_status_to_progress_bar.download_message_displayed = False
|
log_apt_status_to_progress_bar.download_message_displayed = False
|
||||||
|
|
||||||
def strip_boring_dpkg_reading_database(s):
|
def strip_boring_dpkg_reading_database(s):
|
||||||
return re.sub(r'(\(Reading database ... \d*%?|files and directories currently installed.\))', '', s)
|
return re.sub(
|
||||||
|
r"(\(Reading database ... \d*%?|files and directories currently installed.\))",
|
||||||
|
"",
|
||||||
|
s,
|
||||||
|
)
|
||||||
|
|
||||||
callbacks = (
|
callbacks = (
|
||||||
lambda l: logger.debug(strip_boring_dpkg_reading_database(l).rstrip() + "\r"),
|
lambda l: logger.debug(strip_boring_dpkg_reading_database(l).rstrip() + "\r"),
|
||||||
lambda l: logger.warning(l.rstrip() + "\r"), # ... aptitude has no stderr ? :| if _apt_log_line_is_relevant(l.rstrip()) else logger.debug(l.rstrip() + "\r"),
|
lambda l: logger.warning(
|
||||||
|
l.rstrip() + "\r"
|
||||||
|
), # ... aptitude has no stderr ? :| if _apt_log_line_is_relevant(l.rstrip()) else logger.debug(l.rstrip() + "\r"),
|
||||||
lambda l: log_apt_status_to_progress_bar(l.rstrip()),
|
lambda l: log_apt_status_to_progress_bar(l.rstrip()),
|
||||||
)
|
)
|
||||||
|
|
||||||
original_cmd = cmd
|
original_cmd = cmd
|
||||||
cmd = (
|
cmd = f'LC_ALL=C DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none aptitude {cmd} --quiet=2 -o=Dpkg::Use-Pty=0 -o "APT::Status-Fd=$YNH_STDINFO"'
|
||||||
f'LC_ALL=C DEBIAN_FRONTEND=noninteractive APT_LISTCHANGES_FRONTEND=none aptitude {cmd} --quiet=2 -o=Dpkg::Use-Pty=0 -o "APT::Status-Fd=$YNH_STDINFO"'
|
|
||||||
)
|
|
||||||
|
|
||||||
# If upgrading yunohost from the API, delay the Yunohost-api restart
|
# If upgrading yunohost from the API, delay the Yunohost-api restart
|
||||||
# (this should be the last time we need it before bookworm, because on bookworm, yunohost-admin cookies will be persistent upon api restart)
|
# (this should be the last time we need it before bookworm, because on bookworm, yunohost-admin cookies will be persistent upon api restart)
|
||||||
|
@ -304,7 +312,9 @@ def aptitude_with_progress_bar(cmd):
|
||||||
if log_apt_status_to_progress_bar.previous_package is not None and ret == 0:
|
if log_apt_status_to_progress_bar.previous_package is not None and ret == 0:
|
||||||
log_apt_status_to_progress_bar("done::100:Done")
|
log_apt_status_to_progress_bar("done::100:Done")
|
||||||
elif ret != 0:
|
elif ret != 0:
|
||||||
raise YunohostError(f"Failed to run command 'aptitude {original_cmd}'", raw_msg=True)
|
raise YunohostError(
|
||||||
|
f"Failed to run command 'aptitude {original_cmd}'", raw_msg=True
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _apt_log_line_is_relevant(line):
|
def _apt_log_line_is_relevant(line):
|
||||||
|
|
Loading…
Add table
Reference in a new issue