mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Implement / clean strings + fix some edge cases
This commit is contained in:
parent
add3bd29b0
commit
dedc85e52a
2 changed files with 53 additions and 50 deletions
|
@ -369,22 +369,26 @@
|
||||||
"migration_0011_rollback_success": "Rollback succeeded.",
|
"migration_0011_rollback_success": "Rollback succeeded.",
|
||||||
"migration_0011_update_LDAP_database": "Updating LDAP database...",
|
"migration_0011_update_LDAP_database": "Updating LDAP database...",
|
||||||
"migration_0011_update_LDAP_schema": "Updating LDAP schema...",
|
"migration_0011_update_LDAP_schema": "Updating LDAP schema...",
|
||||||
"migrations_backward": "Migrating backward.",
|
"migrations_already_ran": "Those migrations have already been ran: {ids}",
|
||||||
"migrations_bad_value_for_target": "Invalid number for target argument, available migrations numbers are 0 or {}",
|
|
||||||
"migrations_cant_reach_migration_file": "Can't access migrations files at path %s",
|
"migrations_cant_reach_migration_file": "Can't access migrations files at path %s",
|
||||||
"migrations_current_target": "Migration target is {}",
|
"migrations_dependencies_not_satisfied": "Can't run migration {id} because first you need to run these migrations: {dependencies_id}",
|
||||||
"migrations_error_failed_to_load_migration": "ERROR: failed to load migration {number} {name}",
|
"migrations_failed_to_load_migration": "Failed to load migration {id} : {error}",
|
||||||
"migrations_forward": "Migrating forward",
|
"migrations_exclusive_options": "--auto, --skip, --revert and --force-rerun are exclusive options.",
|
||||||
"migrations_list_conflict_pending_done": "You cannot use both --previous and --done at the same time.",
|
"migrations_list_conflict_pending_done": "You cannot use both --previous and --done at the same time.",
|
||||||
"migrations_loading_migration": "Loading migration {number} {name}…",
|
"migrations_loading_migration": "Loading migration {id}…",
|
||||||
"migrations_migration_has_failed": "Migration {number} {name} has failed with exception {exception}, aborting",
|
"migrations_migration_has_failed": "Migration {id} has failed, aborting. Error: {exception}",
|
||||||
|
"migrations_must_provide_explicit_targets": "You must provide explicit targets when using --skip, --revert or --force-rerun",
|
||||||
|
"migrations_need_to_accept_disclaimer": "To run the migration {id}, your must accept the following disclaimer:\n---\n{disclaimer}\n---\nIf you accept to run the migration, please re-run the command with the option --accept-disclaimer.",
|
||||||
"migrations_no_migrations_to_run": "No migrations to run",
|
"migrations_no_migrations_to_run": "No migrations to run",
|
||||||
"migrations_show_currently_running_migration": "Running migration {number} {name}…",
|
"migrations_no_such_migration": "No such migration called {id}",
|
||||||
"migrations_show_last_migration": "Last ran migration is {}",
|
"migrations_not_pending_cant_skip": "Those migrations are not pending so cannot be skipped: {ids}",
|
||||||
"migrations_skip_migration": "Skipping migration {number} {name}…",
|
"migrations_pending_cant_revert_or_rerun": "Those migrations are still pending so cannot be reverted or reran: {ids}",
|
||||||
"migrations_success": "Successfully ran migration {number} {name}!",
|
"migrations_running_forward": "Running migration {id}…",
|
||||||
"migrations_to_be_ran_manually": "Migration {number} {name} has to be ran manually. Please go to Tools > Migrations on the webadmin, or run `yunohost tools migrations migrate`.",
|
"migrations_running_backward": "Attempting to revert migration {id}…",
|
||||||
"migrations_need_to_accept_disclaimer": "To run the migration {number} {name}, your must accept the following disclaimer:\n---\n{disclaimer}\n---\nIf you accept to run the migration, please re-run the command with the option --accept-disclaimer.",
|
"migrations_skip_migration": "Skipping migration {id}…",
|
||||||
|
"migrations_success_forward": "Successfully ran migration {id}!",
|
||||||
|
"migrations_success_revert": "Successfully reverted migration {id}!",
|
||||||
|
"migrations_to_be_ran_manually": "Migration {id} has to be ran manually. Please go to Tools > Migrations on the webadmin, or run `yunohost tools migrations migrate`.",
|
||||||
"monitor_disabled": "The server monitoring has been disabled",
|
"monitor_disabled": "The server monitoring has been disabled",
|
||||||
"monitor_enabled": "The server monitoring has been enabled",
|
"monitor_enabled": "The server monitoring has been enabled",
|
||||||
"monitor_glances_con_failed": "Unable to connect to Glances server",
|
"monitor_glances_con_failed": "Unable to connect to Glances server",
|
||||||
|
|
|
@ -1042,12 +1042,12 @@ def tools_migrations_migrate(targets=[], skip=False, auto=False, force_rerun=Fal
|
||||||
"""
|
"""
|
||||||
Perform migrations
|
Perform migrations
|
||||||
|
|
||||||
targets : a list of migrations to act on (by default : all pending)
|
targets A list migrations to run (all pendings by default)
|
||||||
auto : automatic mode, run only 'automatic' migrations (compared to manual migrations). Option meant to be used in debian's postinst script during upgades.
|
--skip Skip specified migrations (to be used only if you know what you are doing) (must explicit which migrations)
|
||||||
skip : skip specified migrations (must explicit which migrations)
|
--auto Automatic mode, won't run manual migrations (to be used only if you know what you are doing) (must explicit which migrations)
|
||||||
revert : to revert already-ran migrations (must explicit which migrations)
|
--force-rerun Re-run already-ran migrations (to be used only if you know what you are doing)(must explicit which migrations)
|
||||||
force_rerun : to re-run already ran migrations (if you know what you're doing...) (must explicit which migrations)
|
--revert Attempt to revert already-ran migrations (must explicit which migrations)
|
||||||
accept_disclaimer : accept disclaimer for manual migration that requires it (only valid for one migration)
|
--accept-disclaimer Accept disclaimers of migrations (please read them before using this option) (only valid for one migration)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
all_migrations = _get_migrations_list()
|
all_migrations = _get_migrations_list()
|
||||||
|
@ -1058,18 +1058,18 @@ def tools_migrations_migrate(targets=[], skip=False, auto=False, force_rerun=Fal
|
||||||
if m.id == target or m.name == target or m.id.split("_")[0] == target:
|
if m.id == target or m.name == target or m.id.split("_")[0] == target:
|
||||||
return m
|
return m
|
||||||
|
|
||||||
raise YunohostError("No such migration called %s" % target)
|
raise YunohostError("migrations_no_such_migration", id=target)
|
||||||
|
|
||||||
|
|
||||||
# auto, skip, revert and force are exclusive options
|
# auto, skip, revert and force are exclusive options
|
||||||
if auto + skip + revert + force_rerun > 1:
|
if auto + skip + revert + force_rerun > 1:
|
||||||
raise YunohostError("--auto, --skip, --revert and --force-rerun are exclusive options.")
|
raise YunohostError("migrations_exclusive_options")
|
||||||
|
|
||||||
# If no target specified
|
# If no target specified
|
||||||
if not targets:
|
if not targets:
|
||||||
# skip, revert or force require explicit targets
|
# skip, revert or force require explicit targets
|
||||||
if (revert or force_rerun):
|
if (revert or force_rerun):
|
||||||
raise YunohostError("You must provide explicit targets when using --skip, --revert or --force-rerun")
|
raise YunohostError("migrations_must_provide_explicit_targets")
|
||||||
|
|
||||||
# Otherwise, targets are all pending migrations
|
# Otherwise, targets are all pending migrations
|
||||||
targets = [m for m in all_migrations if m.state == "pending"]
|
targets = [m for m in all_migrations if m.state == "pending"]
|
||||||
|
@ -1081,9 +1081,11 @@ def tools_migrations_migrate(targets=[], skip=False, auto=False, force_rerun=Fal
|
||||||
pending = [t.id for t in targets if t.state == "pending"]
|
pending = [t.id for t in targets if t.state == "pending"]
|
||||||
|
|
||||||
if skip and done:
|
if skip and done:
|
||||||
raise YunohostError("Those migrations are not pending so cannot be skipped: %s" % ', '.join(done))
|
raise YunohostError("migrations_not_pending_cant_skip", ids=', '.join(done))
|
||||||
if (revert or force_rerun) and pending:
|
if (revert or force_rerun) and pending:
|
||||||
raise YunohostError("Those migrations were not already ran so cannot be reverted or reran: %s" % ', '.join(pending))
|
raise YunohostError("migrations_pending_cant_revert_or_rerun", ids=', '.join(pending))
|
||||||
|
if not (skip or revert or force_rerun) and done:
|
||||||
|
raise YunohostError("migrations_already_ran", ids=', '.join(done))
|
||||||
|
|
||||||
# So, is there actually something to do ?
|
# So, is there actually something to do ?
|
||||||
if not targets:
|
if not targets:
|
||||||
|
@ -1098,9 +1100,7 @@ def tools_migrations_migrate(targets=[], skip=False, auto=False, force_rerun=Fal
|
||||||
# to be ran manually by the user, stop there and ask the user to
|
# to be ran manually by the user, stop there and ask the user to
|
||||||
# run the migration manually.
|
# run the migration manually.
|
||||||
if auto and migration.mode == "manual":
|
if auto and migration.mode == "manual":
|
||||||
logger.warn(m18n.n('migrations_to_be_ran_manually',
|
logger.warn(m18n.n('migrations_to_be_ran_manually', id=migration.id))
|
||||||
number=migration.number,
|
|
||||||
name=migration.name))
|
|
||||||
|
|
||||||
# We go to the next migration
|
# We go to the next migration
|
||||||
continue
|
continue
|
||||||
|
@ -1110,17 +1110,18 @@ def tools_migrations_migrate(targets=[], skip=False, auto=False, force_rerun=Fal
|
||||||
dependencies = [get_matching_migration(dep) for dep in migration.dependencies]
|
dependencies = [get_matching_migration(dep) for dep in migration.dependencies]
|
||||||
pending_dependencies = [dep.id for dep in dependencies if dep.state == "pending"]
|
pending_dependencies = [dep.id for dep in dependencies if dep.state == "pending"]
|
||||||
if pending_dependencies:
|
if pending_dependencies:
|
||||||
logger.error("Can't run migration %s because first you need to run these migrations: %s" % (migration.id, ', '.join(pending_dependencies)))
|
logger.error(m18n.n('migrations_dependencies_not_satisfied',
|
||||||
|
id=migration.id,
|
||||||
|
dependencies_id=', '.join(pending_dependencies)))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# If some migrations have disclaimers (and we're not trying to skip them)
|
# If some migrations have disclaimers (and we're not trying to skip them)
|
||||||
if migration.disclaimer and not skip:
|
if migration.disclaimer and not skip and not revert:
|
||||||
# require the --accept-disclaimer option.
|
# require the --accept-disclaimer option.
|
||||||
# Otherwise, go to the next migration
|
# Otherwise, go to the next migration
|
||||||
if not accept_disclaimer:
|
if not accept_disclaimer:
|
||||||
logger.warn(m18n.n('migrations_need_to_accept_disclaimer',
|
logger.warn(m18n.n('migrations_need_to_accept_disclaimer',
|
||||||
number=migration.number,
|
id=migration.id,
|
||||||
name=migration.name,
|
|
||||||
disclaimer=migration.disclaimer))
|
disclaimer=migration.disclaimer))
|
||||||
continue
|
continue
|
||||||
# --accept-disclaimer will only work for the first migration
|
# --accept-disclaimer will only work for the first migration
|
||||||
|
@ -1133,35 +1134,37 @@ def tools_migrations_migrate(targets=[], skip=False, auto=False, force_rerun=Fal
|
||||||
operation_logger.start()
|
operation_logger.start()
|
||||||
|
|
||||||
if skip:
|
if skip:
|
||||||
logger.warn(m18n.n('migrations_skip_migration',
|
logger.warn(m18n.n('migrations_skip_migration', id=migration.id))
|
||||||
number=migration.number,
|
migration.state = "skipped"
|
||||||
name=migration.name))
|
|
||||||
_write_migration_state(migration.id, "skipped")
|
_write_migration_state(migration.id, "skipped")
|
||||||
operation_logger.success()
|
operation_logger.success()
|
||||||
else:
|
else:
|
||||||
|
|
||||||
logger.info(m18n.n('migrations_show_currently_running_migration',
|
|
||||||
number=migration.number, name=migration.name))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
migration.operation_logger = operation_logger
|
migration.operation_logger = operation_logger
|
||||||
if revert:
|
if revert:
|
||||||
|
logger.info(m18n.n('migrations_running_backward', id=migration.id))
|
||||||
migration.backward()
|
migration.backward()
|
||||||
else:
|
else:
|
||||||
|
logger.info(m18n.n('migrations_running_forward', id=migration.id))
|
||||||
migration.migrate()
|
migration.migrate()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# migration failed, let's stop here but still update state because
|
# migration failed, let's stop here but still update state because
|
||||||
# we managed to run the previous ones
|
# we managed to run the previous ones
|
||||||
msg = m18n.n('migrations_migration_has_failed',
|
msg = m18n.n('migrations_migration_has_failed',
|
||||||
exception=e,
|
exception=e, id=migration.id)
|
||||||
number=migration.number,
|
|
||||||
name=migration.name)
|
|
||||||
logger.error(msg, exc_info=1)
|
logger.error(msg, exc_info=1)
|
||||||
operation_logger.error(msg)
|
operation_logger.error(msg)
|
||||||
else:
|
else:
|
||||||
logger.success(m18n.n('migrations_success',
|
if revert:
|
||||||
number=migration.number, name=migration.name))
|
logger.success(m18n.n('migrations_success_revert', id=migration.id))
|
||||||
_write_migration_state(migration.id, "done")
|
migration.state = "pending"
|
||||||
|
_write_migration_state(migration.id, "pending")
|
||||||
|
else:
|
||||||
|
logger.success(m18n.n('migrations_success_forward', id=migration.id))
|
||||||
|
migration.state = "done"
|
||||||
|
_write_migration_state(migration.id, "done")
|
||||||
|
|
||||||
operation_logger.success()
|
operation_logger.success()
|
||||||
|
|
||||||
|
|
||||||
|
@ -1274,10 +1277,7 @@ def _load_migration(migration_file):
|
||||||
|
|
||||||
migration_id = migration_file[:-len(".py")]
|
migration_id = migration_file[:-len(".py")]
|
||||||
|
|
||||||
number, name = migration_id.split("_", 1)
|
logger.debug(m18n.n('migrations_loading_migration', id=migration_id))
|
||||||
|
|
||||||
logger.debug(m18n.n('migrations_loading_migration',
|
|
||||||
number=number, name=name))
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# this is python builtin method to import a module using a name, we
|
# this is python builtin method to import a module using a name, we
|
||||||
|
@ -1285,12 +1285,11 @@ def _load_migration(migration_file):
|
||||||
# able to run it in the next loop
|
# able to run it in the next loop
|
||||||
module = import_module("yunohost.data_migrations.{}".format(migration_id))
|
module = import_module("yunohost.data_migrations.{}".format(migration_id))
|
||||||
return module.MyMigration(migration_id)
|
return module.MyMigration(migration_id)
|
||||||
except Exception:
|
except Exception as e:
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
raise YunohostError('migrations_error_failed_to_load_migration',
|
raise YunohostError('migrations_failed_to_load_migration', id=migration_id, error=e)
|
||||||
number=number, name=name)
|
|
||||||
|
|
||||||
|
|
||||||
def _skip_all_migrations():
|
def _skip_all_migrations():
|
||||||
|
|
Loading…
Add table
Reference in a new issue