From ff2bbb0377ae71148a21c6027d015493e2fd8565 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 10 Sep 2019 14:08:19 +0200 Subject: [PATCH 1/2] Fix / remove stale i18n strings --- locales/en.json | 26 +------------------------- src/yunohost/app.py | 2 +- src/yunohost/tools.py | 2 +- tests/_test_m18nkeys.py | 39 +++++++++++++++++++++++++++++---------- 4 files changed, 32 insertions(+), 37 deletions(-) diff --git a/locales/en.json b/locales/en.json index 2d708279d..a4f5ec9da 100644 --- a/locales/en.json +++ b/locales/en.json @@ -14,7 +14,6 @@ "app_argument_choice_invalid": "Use one of these choices '{choices:s}' for the argument '{name:s}'", "app_argument_invalid": "Pick a valid value for the argument '{name:s}': {error:s}", "app_argument_required": "Argument '{name:s}' is required", - "app_change_no_change_url_script": "The application {app_name:s} doesn't support changing its URL yet, you might need to upgrade it.", "app_change_url_failed_nginx_reload": "Could not reload NGINX. Here is the output of 'nginx -t':\n{nginx_errors:s}", "app_change_url_identical_domains": "The old and new domain/url_path are identical ('{domain:s}{path:s}'), nothing to do.", "app_change_url_no_script": "This application '{app_name:s}' doesn't support URL modification yet. Maybe you should upgrade it.", @@ -75,7 +74,6 @@ "ask_password": "Password", "ask_path": "Path", "backup_abstract_method": "This backup method has yet to be implemented", - "backup_action_required": "You must specify something to save", "backup_actually_backuping": "Creating a backup archive from the collected files…", "backup_app_failed": "Could not back up the app '{app:s}'", "backup_applying_method_borg": "Sending all files to backup into borg-backup repository…", @@ -84,7 +82,6 @@ "backup_applying_method_tar": "Creating the backup TAR archive…", "backup_archive_app_not_found": "Could not find the app '{app:s}' in the backup archive", "backup_archive_broken_link": "Could not access the backup archive (broken link to {path:s})", - "backup_archive_mount_failed": "Could not mount the backup archive", "backup_archive_name_exists": "A backup archive with this name already exists.", "backup_archive_name_unknown": "Unknown local backup archive named '{name:s}'", "backup_archive_open_failed": "Could not open the backup archive", @@ -97,16 +94,13 @@ "backup_copying_to_organize_the_archive": "Copying {size:s}MB to organize the archive", "backup_couldnt_bind": "Could not bind {src:s} to {dest:s}.", "backup_created": "Backup created", - "backup_creating_archive": "Creating the backup archive…", "backup_creation_failed": "Could not create the backup archive", "backup_csv_addition_failed": "Could not add files to backup into the CSV file", "backup_csv_creation_failed": "Could not create the CSV file needed for restoration", "backup_custom_backup_error": "Custom backup method could not get past the 'backup' step", "backup_custom_mount_error": "Custom backup method could not get past the 'mount' step", - "backup_custom_need_mount_error": "Custom backup method could not get past 'need_mount' step", "backup_delete_error": "Could not delete '{path:s}'", "backup_deleted": "Backup deleted", - "backup_extracting_archive": "Extracting backup archive…", "backup_hook_unknown": "The backup hook '{hook:s}' is unknown", "backup_invalid_archive": "This is not a backup archive", "backup_method_borg_finished": "Backup into Borg finished", @@ -142,7 +136,6 @@ "certmanager_domain_cert_not_selfsigned": "The certificate for domain {domain:s} is not self-signed. Are you sure you want to replace it? (Use '--force' to do so.)", "certmanager_domain_dns_ip_differs_from_public_ip": "The DNS 'A' record for the domain '{domain:s}' is different from this server IP. If you recently modified your A record, please wait for it to propagate (some DNS propagation checkers are available online). (If you know what you are doing, use '--no-checks' to turn off those checks.)", "certmanager_domain_http_not_working": "It seems the domain {domain:s} cannot be accessed through HTTP. Check that your DNS and NGINX configuration is correct", - "certmanager_domain_not_resolved_locally": "The domain {domain:s} cannot be resolved from inside your YunoHost server. This might happen if you recently modified your DNS record. If so, please wait a few hours for it to propagate. If the issue persists, consider adding {domain:s} to /etc/hosts. (If you know what you are doing, use '--no-checks' to turn off those checks.)", "certmanager_domain_unknown": "Unknown domain '{domain:s}'", "certmanager_error_no_A_record": "No DNS 'A' record found for '{domain:s}'. You need to make your domain name point to your machine to be able to install a Let's Encrypt certificate. (If you know what you are doing, use '--no-checks' to turn off those checks.)", "certmanager_hit_rate_limit": "Too many certificates already issued for this exact set of domains {domain:s} recently. Please try again later. See https://letsencrypt.org/docs/rate-limits/ for more details", @@ -158,12 +151,10 @@ "diagnosis_debian_version_error": "Could not retrieve the Debian version: {error}", "diagnosis_kernel_version_error": "Could not retrieve kernel version: {error}", "diagnosis_monitor_disk_error": "Could not monitor disks: {error}", - "diagnosis_monitor_network_error": "Could not monitor network: {error}", "diagnosis_monitor_system_error": "Could not monitor system: {error}", "diagnosis_no_apps": "No installed application", "dpkg_is_broken": "You cannot do this right now because dpkg/APT (the system package managers) seems to be in a broken state… You can try to solve this issue by connecting through SSH and running `sudo dpkg --configure -a`.", "dpkg_lock_not_available": "This command can't be ran right now because another program seems to be using the lock of dpkg (the system package manager)", - "dnsmasq_isnt_installed": "Dnsmasq does not seem to be installed, please run 'apt-get remove bind9 && apt-get install it'", "domain_cannot_remove_main": "Cannot remove main domain. Set one first", "domain_cert_gen_failed": "Could not generate certificate", "domain_created": "Domain created", @@ -172,15 +163,11 @@ "domain_deletion_failed": "Could not delete domain", "domain_dns_conf_is_just_a_recommendation": "This command shows you the *recommended* configuration. It does not actually set up the DNS configuration for you. It is your responsability to configure your DNS zone in your registrar according to this recommendation.", "domain_dyndns_already_subscribed": "You have already subscribed to a DynDNS domain", - "domain_dyndns_dynette_is_unreachable": "Could not reach YunoHost dynette, either your YunoHost is not correctly connected to the Internet, or the dynette server is down. Error: {error}", - "domain_dyndns_invalid": "This domain can not be used with DynDNS", "domain_dyndns_root_unknown": "Unknown DynDNS root domain", "domain_exists": "The domain already exists", "domain_hostname_failed": "Could not set new hostname. This might cause an issue later (it might be fine).", "domain_uninstall_app_first": "One or more apps are installed on this domain. Please uninstall them before proceeding to domain removal", "domain_unknown": "Unknown domain", - "domain_zone_exists": "DNS zone file already exists", - "domain_zone_not_found": "DNS zone file not found for domain {:s}", "domains_available": "Available domains:", "done": "Done", "downloading": "Downloading…", @@ -194,6 +181,7 @@ "dyndns_key_generating": "Generating DNS key… It may take a while.", "dyndns_key_not_found": "DNS key not found for the domain", "dyndns_no_domain_registered": "No domain registered with DynDNS", + "dyndns_provider_unreachable": "Unable to reach Dyndns provider {provider}: either your YunoHost is not correctly connected to the internet or the dynette server is down.", "dyndns_registered": "DynDNS domain registered", "dyndns_registration_failed": "Could not register DynDNS domain: {error:s}", "dyndns_domain_not_provided": "DynDNS provider {provider:s} cannot provide domain {domain:s}.", @@ -210,7 +198,6 @@ "firewall_reload_failed": "Could not reload the firewall", "firewall_reloaded": "Firewall reloaded", "firewall_rules_cmd_failed": "Some firewall rules commands have failed. More info in log.", - "format_datetime_short": "%m/%d/%Y %I:%M %p", "global_settings_bad_choice_for_enum": "Bad choice for setting {setting:s}, received '{choice:s}', but available choices are: {available_choices:s}", "global_settings_bad_type_for_setting": "Bad type for setting {setting:s}, received {received_type:s}, expected {expected_type:s}", "global_settings_cant_open_settings": "Could not open settings file, reason: {reason:s}", @@ -240,7 +227,6 @@ "group_deleted": "Group '{group}' deleted", "group_deletion_failed": "Could not delete the group '{group}'", "group_deletion_not_allowed": "The group {group:s} cannot be deleted manually.", - "group_info_failed": "Could not present group info", "group_unknown": "The group '{group:s}' is unknown", "group_updated": "Group '{group}' updated", "group_update_failed": "Could not update the group '{group}'", @@ -251,7 +237,6 @@ "hook_name_unknown": "Unknown hook name '{name:s}'", "installation_complete": "Installation complete", "installation_failed": "Something went wrong with the installation", - "invalid_url_format": "Something is wrong with the URL", "ip6tables_unavailable": "You cannot play with ip6tables here. You are either in a container or your kernel does not support it", "iptables_unavailable": "You cannot play with iptables here. You are either in a container or your kernel does not support it", "log_corrupted_md_file": "The YAML metadata file associated with logs is damaged: '{md_file}\nError: {error}'", @@ -403,24 +388,18 @@ "network_check_mx_ko": "DNS MX record is not set", "network_check_smtp_ko": "Outbound e-mail (SMTP port 25) seems to be blocked by your network", "network_check_smtp_ok": "Outbound e-mail (SMTP port 25) is not blocked", - "new_domain_required": "You must provide the new main domain", - "no_appslist_found": "No app list found", "no_internet_connection": "Server not connected to the Internet", - "no_ipv6_connectivity": "IPv6 connectivity is not available", - "no_restore_script": "No restore script found for the app '{app:s}'", "not_enough_disk_space": "Not enough free space on '{path:s}'", "operation_interrupted": "The operation was manually interrupted?", "package_not_installed": "Package '{pkgname}' is not installed", "package_unexpected_error": "An unexpected error occurred processing the package '{pkgname}'", "package_unknown": "Unknown package '{pkgname}'", - "packages_upgrade_critical_later": "Critical packages ({packages:s}) will be upgraded later", "packages_upgrade_failed": "Could not upgrade all the packages", "password_listed": "This password is among the most used password in the world. Please choose something more unique.", "password_too_simple_1": "The password needs to be at least 8 characters long", "password_too_simple_2": "The password needs to be at least 8 characters long and contain a digit, upper and lower characters", "password_too_simple_3": "The password needs to be at least 8 characters long and contain a digit, upper, lower and special characters", "password_too_simple_4": "The password needs to be at least 12 characters long and contain a digit, upper, lower and special characters", - "path_removal_failed": "Could not remove path {:s}", "pattern_backup_archive_name": "Must be a valid filename with max 30 characters, alphanumeric and -_. characters only", "pattern_domain": "Must be a valid domain name (e.g. my-domain.org)", "pattern_email": "Must be a valid email address (e.g. someone@domain.org)", @@ -468,7 +447,6 @@ "regenconf_dry_pending_applying": "Checking pending configuration which would have been applied for category '{category}'…", "regenconf_failed": "Could not regenerate the configuration for category(s): {categories}", "regenconf_pending_applying": "Applying pending configuration for category '{category}'…", - "restore_action_required": "You must pick something to restore", "restore_already_installed_app": "An app with the ID '{app:s}' is already installed", "restore_app_failed": "Could not restore the app '{app:s}'", "restore_cleaning_failed": "Could not clean up the temporary restoration directory", @@ -478,7 +456,6 @@ "restore_failed": "Could not restore system", "restore_hook_unavailable": "The restoration script for '{part:s}' not available on your system and not in the archive either", "restore_may_be_not_enough_disk_space": "Your system seems does not have enough space (free: {free_space:d} B, needed space: {needed_space:d} B, security margin: {margin:d} B)", - "restore_mounting_archive": "Mounting archive into '{path:s}'", "restore_not_enough_disk_space": "Not enough space (space: {free_space:d} B, needed space: {needed_space:d} B, security margin: {margin:d} B)", "restore_nothings_done": "Nothing was restored", "restore_removing_tmp_dir_failed": "Could not remove an old temporary directory", @@ -530,7 +507,6 @@ "service_reloaded_or_restarted": "'{service:s}' service reloaded or restarted", "service_start_failed": "Could not start the service '{service:s}'\n\nRecent service logs:{logs:s}", "service_started": "'{service:s}' service started", - "service_status_failed": "Could not determine status of the service '{service:s}'", "service_stop_failed": "Could not stop the service '{service:s}'\n\nRecent service logs:{logs:s}", "service_stopped": "'{service:s}' service stopped", "service_unknown": "Unknown service '{service:s}'", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index c93c7ba80..0d30a2da3 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -472,7 +472,7 @@ def app_change_url(operation_logger, app, domain, path): raise YunohostError('app_not_installed', app=app, all_apps=_get_all_installed_apps_id()) if not os.path.exists(os.path.join(APPS_SETTING_PATH, app, "scripts", "change_url")): - raise YunohostError("app_change_no_change_url_script", app_name=app) + raise YunohostError("app_change_url_no_script", app_name=app) old_domain = app_setting(app, "domain") old_path = app_setting(app, "path") diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index 5ff5d64fc..eb2fc5cc6 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -657,7 +657,7 @@ def tools_upgrade(operation_logger, apps=None, system=False): ) returncode = call_async_output(dist_upgrade, callbacks, shell=True) if returncode != 0: - logger.warning('tools_upgrade_regular_packages_failed', + logger.warning(m18n.n('tools_upgrade_regular_packages_failed'), packages_list=', '.join(noncritical_packages_upgradable)) operation_logger.error(m18n.n('packages_upgrade_failed')) raise YunohostError(m18n.n('packages_upgrade_failed')) diff --git a/tests/_test_m18nkeys.py b/tests/_test_m18nkeys.py index ee8df0dc6..cc6202517 100644 --- a/tests/_test_m18nkeys.py +++ b/tests/_test_m18nkeys.py @@ -5,23 +5,37 @@ import glob import json import yaml +ignore = [ "service_description_", + "migration_description_", + "global_settings_setting_", + "password_too_simple_", + "password_listed", + "backup_method_", + "backup_applying_method_", + "confirm_app_install_", + "log_", + ] + ############################################################################### # Find used keys in python code # ############################################################################### # This regex matches « foo » in patterns like « m18n.n( "foo" » -p = re.compile(r'm18n\.n\(\s*[\"\']([a-zA-Z1-9_]+)[\"\']') +p1 = re.compile(r'm18n\.n\(\s*[\"\']([a-zA-Z0-9_]+)[\"\']') +p2 = re.compile(r'YunohostError\([\'\"]([a-zA-Z0-9_]+)[\'\"]') -python_files = glob.glob("/vagrant/yunohost/src/yunohost/*.py") -python_files.extend(glob.glob("/vagrant/yunohost/src/yunohost/utils/*.py")) -python_files.append("/vagrant/yunohost/bin/yunohost") +python_files = glob.glob("../src/yunohost/*.py") +python_files.extend(glob.glob("../src/yunohost/utils/*.py")) +python_files.extend(glob.glob("../src/yunohost/data_migrations/*.py")) +python_files.append("../bin/yunohost") python_keys = set() for python_file in python_files: - with open(python_file) as f: - keys_in_file = p.findall(f.read()) - for key in keys_in_file: - python_keys.add(key) + content = open(python_file).read() + for match in p1.findall(content): + python_keys.add(match) + for match in p2.findall(content): + python_keys.add(match) ############################################################################### # Find keys used in actionmap # @@ -42,19 +56,20 @@ for _, category in actionmap.items(): actionmap_keys.add(argument["extra"]["password"]) if "ask" in argument["extra"]: actionmap_keys.add(argument["extra"]["ask"]) + if "comment" in argument["extra"]: + actionmap_keys.add(argument["extra"]["comment"]) if "pattern" in argument["extra"]: actionmap_keys.add(argument["extra"]["pattern"][1]) if "help" in argument["extra"]: print argument["extra"]["help"] -# These keys are used but difficult to parse actionmap_keys.add("admin_password") ############################################################################### # Load en locale json keys # ############################################################################### -en_locale_file = "/vagrant/yunohost/locales/en.json" +en_locale_file = "../locales/en.json" with open(en_locale_file) as f: en_locale_json = json.loads(f.read()) @@ -72,11 +87,15 @@ keys_defined_but_not_used = en_locale_keys.difference(used_keys) if len(keys_used_but_not_defined) != 0: print "> Error ! Those keys are used in some files but not defined :" for key in sorted(keys_used_but_not_defined): + if any(key.startswith(i) for i in ignore): + continue print " - %s" % key if len(keys_defined_but_not_used) != 0: print "> Warning ! Those keys are defined but seems unused :" for key in sorted(keys_defined_but_not_used): + if any(key.startswith(i) for i in ignore): + continue print " - %s" % key From 6ed062b41bc106e9b84fbbc6c9828569926e6b89 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Fri, 20 Sep 2019 14:49:31 +0200 Subject: [PATCH 2/2] app_no_upgrade -> apps_already_up_to_date --- locales/en.json | 2 +- src/yunohost/app.py | 4 ++-- src/yunohost/tools.py | 5 +---- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/locales/en.json b/locales/en.json index a4f5ec9da..61fdcfa9b 100644 --- a/locales/en.json +++ b/locales/en.json @@ -27,7 +27,6 @@ "app_location_install_failed": "Cannot install the app there because it conflicts with the app '{other_app}' already installed in '{other_path}'", "app_location_unavailable": "This URL is either unavailable, or conflicts with the already installed app(s):\n{apps:s}", "app_manifest_invalid": "Something is wrong with the app manifest: {error}", - "app_no_upgrade": "All applications are already up-to-date", "app_not_upgraded": "The app '{failed_app}' failed to upgrade, and as a consequence the following apps upgrades have been cancelled: {apps}", "app_upgrade_stopped": "The upgrade of all applications has been stopped to prevent possible damage because the previous application failed to upgrade", "app_not_correctly_installed": "{app:s} seems to be incorrectly installed", @@ -50,6 +49,7 @@ "app_upgrade_failed": "Could not upgrade {app:s}", "app_upgrade_some_app_failed": "Some applications could not be upgraded", "app_upgraded": "{app:s} upgraded", + "apps_already_up_to_date": "All applications are already up-to-date", "apps_permission_not_found": "No permission found for the installed apps", "apps_permission_restoration_failed": "Grant the permission permission '{permission:s}' to restore {app:s}", "appslist_corrupted_json": "Could not load the application lists. It looks like {filename:s} is damaged.", diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 0d30a2da3..5a51e57bb 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -590,7 +590,7 @@ def app_upgrade(app=[], url=None, file=None): try: app_list() except YunohostError: - raise YunohostError('app_no_upgrade') + raise YunohostError('apps_already_up_to_date') not_upgraded_apps = [] @@ -611,7 +611,7 @@ def app_upgrade(app=[], url=None, file=None): raise YunohostError('app_not_installed', app=app, all_apps=_get_all_installed_apps_id()) if len(apps) == 0: - raise YunohostError('app_no_upgrade') + raise YunohostError('apps_already_up_to_date') if len(apps) > 1: logger.info(m18n.n("app_upgrade_several_apps", apps=", ".join(apps))) diff --git a/src/yunohost/tools.py b/src/yunohost/tools.py index eb2fc5cc6..64689fe0c 100644 --- a/src/yunohost/tools.py +++ b/src/yunohost/tools.py @@ -584,10 +584,7 @@ def tools_upgrade(operation_logger, apps=None, system=False): upgradable_apps = [app["id"] for app in _list_upgradable_apps()] - if not upgradable_apps: - logger.info(m18n.n("app_no_upgrade")) - return - elif len(apps) and all(app not in upgradable_apps for app in apps): + if not upgradable_apps or (len(apps) and all(app not in upgradable_apps for app in apps)): logger.info(m18n.n("apps_already_up_to_date")) return