mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[CI] Format code with Black
This commit is contained in:
parent
8a9ed1ed7a
commit
8cef37d704
4 changed files with 68 additions and 37 deletions
|
@ -308,7 +308,6 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
tools_upgrade(target="system", postupgradecmds=postupgradecmds)
|
tools_upgrade(target="system", postupgradecmds=postupgradecmds)
|
||||||
|
|
||||||
|
|
||||||
def debian_major_version(self):
|
def debian_major_version(self):
|
||||||
# The python module "platform" and lsb_release are not reliable because
|
# The python module "platform" and lsb_release are not reliable because
|
||||||
# on some setup, they may still return Release=9 even after upgrading to
|
# on some setup, they may still return Release=9 even after upgrading to
|
||||||
|
@ -344,7 +343,9 @@ class MyMigration(Migration):
|
||||||
# Check system is up to date
|
# Check system is up to date
|
||||||
# (but we don't if 'bullseye' is already in the sources.list ...
|
# (but we don't if 'bullseye' is already in the sources.list ...
|
||||||
# which means maybe a previous upgrade crashed and we're re-running it)
|
# which means maybe a previous upgrade crashed and we're re-running it)
|
||||||
if os.path.exists("/etc/apt/sources.list") and " bullseye " not in read_file("/etc/apt/sources.list"):
|
if os.path.exists("/etc/apt/sources.list") and " bullseye " not in read_file(
|
||||||
|
"/etc/apt/sources.list"
|
||||||
|
):
|
||||||
tools_update(target="system")
|
tools_update(target="system")
|
||||||
upgradable_system_packages = list(_list_upgradable_apt_packages())
|
upgradable_system_packages = list(_list_upgradable_apt_packages())
|
||||||
upgradable_system_packages = [
|
upgradable_system_packages = [
|
||||||
|
|
|
@ -37,7 +37,9 @@ def _get_all_venvs(dir, level=0, maxlevel=3):
|
||||||
path = os.path.join(dir, file)
|
path = os.path.join(dir, file)
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
activatepath = os.path.join(path, "bin", "activate")
|
activatepath = os.path.join(path, "bin", "activate")
|
||||||
if os.path.isfile(activatepath) and os.path.isfile(path + VENV_REQUIREMENTS_SUFFIX):
|
if os.path.isfile(activatepath) and os.path.isfile(
|
||||||
|
path + VENV_REQUIREMENTS_SUFFIX
|
||||||
|
):
|
||||||
result.append(path)
|
result.append(path)
|
||||||
continue
|
continue
|
||||||
if level < maxlevel:
|
if level < maxlevel:
|
||||||
|
@ -50,6 +52,7 @@ class MyMigration(Migration):
|
||||||
After the update, recreate a python virtual env based on the previously
|
After the update, recreate a python virtual env based on the previously
|
||||||
generated requirements file
|
generated requirements file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
ignored_python_apps = [
|
ignored_python_apps = [
|
||||||
"calibreweb",
|
"calibreweb",
|
||||||
"django-for-runners",
|
"django-for-runners",
|
||||||
|
@ -62,7 +65,7 @@ class MyMigration(Migration):
|
||||||
"pgadmin",
|
"pgadmin",
|
||||||
"tracim",
|
"tracim",
|
||||||
"synapse",
|
"synapse",
|
||||||
"weblate"
|
"weblate",
|
||||||
]
|
]
|
||||||
|
|
||||||
dependencies = ["migrate_to_bullseye"]
|
dependencies = ["migrate_to_bullseye"]
|
||||||
|
@ -70,7 +73,9 @@ class MyMigration(Migration):
|
||||||
|
|
||||||
def is_pending(self):
|
def is_pending(self):
|
||||||
if not self.state:
|
if not self.state:
|
||||||
self.state = tools_migrations_state()["migrations"].get("0024_rebuild_python_venv", "pending")
|
self.state = tools_migrations_state()["migrations"].get(
|
||||||
|
"0024_rebuild_python_venv", "pending"
|
||||||
|
)
|
||||||
return self.state == "pending"
|
return self.state == "pending"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -101,18 +106,25 @@ class MyMigration(Migration):
|
||||||
app_corresponding_to_venv = extract_app_from_venv_path(venv)
|
app_corresponding_to_venv = extract_app_from_venv_path(venv)
|
||||||
|
|
||||||
# Search for ignore apps
|
# Search for ignore apps
|
||||||
if any(app_corresponding_to_venv.startswith(app) for app in self.ignored_python_apps):
|
if any(
|
||||||
|
app_corresponding_to_venv.startswith(app)
|
||||||
|
for app in self.ignored_python_apps
|
||||||
|
):
|
||||||
ignored_apps.append(app_corresponding_to_venv)
|
ignored_apps.append(app_corresponding_to_venv)
|
||||||
else:
|
else:
|
||||||
rebuild_apps.append(app_corresponding_to_venv)
|
rebuild_apps.append(app_corresponding_to_venv)
|
||||||
|
|
||||||
msg = m18n.n("migration_0024_rebuild_python_venv_disclaimer_base")
|
msg = m18n.n("migration_0024_rebuild_python_venv_disclaimer_base")
|
||||||
if rebuild_apps:
|
if rebuild_apps:
|
||||||
msg += "\n\n" + m18n.n("migration_0024_rebuild_python_venv_disclaimer_rebuild",
|
msg += "\n\n" + m18n.n(
|
||||||
rebuild_apps="\n - " + "\n - ".join(rebuild_apps))
|
"migration_0024_rebuild_python_venv_disclaimer_rebuild",
|
||||||
|
rebuild_apps="\n - " + "\n - ".join(rebuild_apps),
|
||||||
|
)
|
||||||
if ignored_apps:
|
if ignored_apps:
|
||||||
msg += "\n\n" + m18n.n("migration_0024_rebuild_python_venv_disclaimer_ignored",
|
msg += "\n\n" + m18n.n(
|
||||||
ignored_apps="\n - " + "\n - ".join(ignored_apps))
|
"migration_0024_rebuild_python_venv_disclaimer_ignored",
|
||||||
|
ignored_apps="\n - " + "\n - ".join(ignored_apps),
|
||||||
|
)
|
||||||
|
|
||||||
return msg
|
return msg
|
||||||
|
|
||||||
|
@ -124,25 +136,43 @@ class MyMigration(Migration):
|
||||||
app_corresponding_to_venv = extract_app_from_venv_path(venv)
|
app_corresponding_to_venv = extract_app_from_venv_path(venv)
|
||||||
|
|
||||||
# Search for ignore apps
|
# Search for ignore apps
|
||||||
if any(app_corresponding_to_venv.startswith(app) for app in self.ignored_python_apps):
|
if any(
|
||||||
|
app_corresponding_to_venv.startswith(app)
|
||||||
|
for app in self.ignored_python_apps
|
||||||
|
):
|
||||||
rm(venv + VENV_REQUIREMENTS_SUFFIX)
|
rm(venv + VENV_REQUIREMENTS_SUFFIX)
|
||||||
logger.info(m18n.n("migration_0024_rebuild_python_venv_broken_app", app=app_corresponding_to_venv))
|
logger.info(
|
||||||
|
m18n.n(
|
||||||
|
"migration_0024_rebuild_python_venv_broken_app",
|
||||||
|
app=app_corresponding_to_venv,
|
||||||
|
)
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.info(m18n.n("migration_0024_rebuild_python_venv_in_progress", app=app_corresponding_to_venv))
|
logger.info(
|
||||||
|
m18n.n(
|
||||||
|
"migration_0024_rebuild_python_venv_in_progress",
|
||||||
|
app=app_corresponding_to_venv,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
# Recreate the venv
|
# Recreate the venv
|
||||||
rm(venv, recursive=True)
|
rm(venv, recursive=True)
|
||||||
callbacks = (
|
callbacks = (
|
||||||
lambda l: logger.debug("+ " + l.rstrip() + "\r"),
|
lambda l: logger.debug("+ " + l.rstrip() + "\r"),
|
||||||
lambda l: logger.warning(l.rstrip())
|
lambda l: logger.warning(l.rstrip()),
|
||||||
)
|
)
|
||||||
call_async_output(["python", "-m", "venv", venv], callbacks)
|
call_async_output(["python", "-m", "venv", venv], callbacks)
|
||||||
status = call_async_output([
|
status = call_async_output(
|
||||||
f"{venv}/bin/pip", "install", "-r",
|
[f"{venv}/bin/pip", "install", "-r", venv + VENV_REQUIREMENTS_SUFFIX],
|
||||||
venv + VENV_REQUIREMENTS_SUFFIX], callbacks)
|
callbacks,
|
||||||
|
)
|
||||||
if status != 0:
|
if status != 0:
|
||||||
logger.error(m18n.n("migration_0024_rebuild_python_venv_failed",
|
logger.error(
|
||||||
app=app_corresponding_to_venv))
|
m18n.n(
|
||||||
|
"migration_0024_rebuild_python_venv_failed",
|
||||||
|
app=app_corresponding_to_venv,
|
||||||
|
)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
rm(venv + VENV_REQUIREMENTS_SUFFIX)
|
rm(venv + VENV_REQUIREMENTS_SUFFIX)
|
||||||
|
|
|
@ -73,7 +73,7 @@ def tools_adminpw(new_password, check_strength=True):
|
||||||
from yunohost.user import _hash_user_password
|
from yunohost.user import _hash_user_password
|
||||||
from yunohost.utils.password import (
|
from yunohost.utils.password import (
|
||||||
assert_password_is_strong_enough,
|
assert_password_is_strong_enough,
|
||||||
assert_password_is_compatible
|
assert_password_is_compatible,
|
||||||
)
|
)
|
||||||
import spwd
|
import spwd
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ def tools_postinstall(
|
||||||
from yunohost.utils.dns import is_yunohost_dyndns_domain
|
from yunohost.utils.dns import is_yunohost_dyndns_domain
|
||||||
from yunohost.utils.password import (
|
from yunohost.utils.password import (
|
||||||
assert_password_is_strong_enough,
|
assert_password_is_strong_enough,
|
||||||
assert_password_is_compatible
|
assert_password_is_compatible,
|
||||||
)
|
)
|
||||||
from yunohost.domain import domain_main_domain
|
from yunohost.domain import domain_main_domain
|
||||||
import psutil
|
import psutil
|
||||||
|
|
|
@ -145,7 +145,7 @@ def user_create(
|
||||||
from yunohost.hook import hook_callback
|
from yunohost.hook import hook_callback
|
||||||
from yunohost.utils.password import (
|
from yunohost.utils.password import (
|
||||||
assert_password_is_strong_enough,
|
assert_password_is_strong_enough,
|
||||||
assert_password_is_compatible
|
assert_password_is_compatible,
|
||||||
)
|
)
|
||||||
from yunohost.utils.ldap import _get_ldap_interface
|
from yunohost.utils.ldap import _get_ldap_interface
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ def user_update(
|
||||||
from yunohost.app import app_ssowatconf
|
from yunohost.app import app_ssowatconf
|
||||||
from yunohost.utils.password import (
|
from yunohost.utils.password import (
|
||||||
assert_password_is_strong_enough,
|
assert_password_is_strong_enough,
|
||||||
assert_password_is_compatible
|
assert_password_is_compatible,
|
||||||
)
|
)
|
||||||
from yunohost.utils.ldap import _get_ldap_interface
|
from yunohost.utils.ldap import _get_ldap_interface
|
||||||
from yunohost.hook import hook_callback
|
from yunohost.hook import hook_callback
|
||||||
|
|
Loading…
Add table
Reference in a new issue