From 40b93f85542d47fbca9349838cb7ac60d49ed148 Mon Sep 17 00:00:00 2001 From: Alexandre Iooss <erdnaxe@crans.org> Date: Tue, 14 Apr 2020 12:27:51 +0200 Subject: [PATCH] Translation script --- README.rst | 6 ++ cpasswords/client.py | 52 +++------- cpasswords/locale/fr/LC_MESSAGES/messages.po | 100 ++++++++----------- docs/update_locales.sh | 5 + 4 files changed, 65 insertions(+), 98 deletions(-) create mode 100755 docs/update_locales.sh diff --git a/README.rst b/README.rst index 1773948..3067b8f 100644 --- a/README.rst +++ b/README.rst @@ -54,6 +54,12 @@ With a Python virtualenv, Then you will be able to launch the client with ``cpasswords`` or the server with ``cpasswords-server``. +Update recipients +~~~~~~~~~~~~~~~~~ + +If you added a recipient in a role, you should use ``--recrypt`` to recrypt +all files. + Change command name ~~~~~~~~~~~~~~~~~~~ diff --git a/cpasswords/client.py b/cpasswords/client.py index 24ef6f9..f860735 100755 --- a/cpasswords/client.py +++ b/cpasswords/client.py @@ -89,22 +89,17 @@ class SimpleMemoize(object): # Remote commands @SimpleMemoize -def create_ssh_client(options): +def create_ssh_client(host): """ Create a SSH client with paramiko module """ - if "host" not in options.serverdata: - log.error("Missing parameter `host` in active server configuration") - exit(1) - # Create SSH client with system host keys and agent client = SSHClient() client.load_system_host_keys() try: - client.connect(str(options.serverdata['host'])) + client.connect(host) except SSHException: - log.error( - "Host key is unknown or you are using a outdated python-paramiko (ssh-ed25519 was implemented in 2017)") + log.error("An error occured during SSH connection, debug with -vv") raise return client @@ -114,7 +109,10 @@ def remote_command(options, command, arg=None, stdin_contents=None): """ Execute remote command and return output """ - client = create_ssh_client(options) + if "host" not in options.serverdata: + log.error("Missing parameter `host` in active server configuration") + exit(1) + client = create_ssh_client(str(options.serverdata['host'])) # Build command if "remote_cmd" not in options.serverdata: @@ -830,15 +828,9 @@ def main(): '--roles', nargs='?', default=None, - help=_("""Liste de roles (séparés par des virgules). Par défaut, tous les - rôles en écriture (sauf pour l'édition, d'un fichier existant). - Avec --edit: le fichier sera chiffré pour exactement ces roles - Avec --(strict-)recrypt-files : - sert à sélectionnenr les fichiers à rechiffrer - * non-strict: tout fichier possédant un des rôles listé - * strict: tout fichier dont *tous* les rôles sont dans la - liste - """)) + help=_("specify for which roles to crypt (default to all roles, or do " + "not change if editing)"), + ) # Actions possibles arg_grp = parser.add_argument_group("actions") @@ -847,7 +839,6 @@ def main(): '--view', action='store_const', dest='action', - default=show_file, const=show_file, help=_("read file (default)"), ) @@ -855,7 +846,6 @@ def main(): '-e', '--edit', action='store_const', dest='action', - default=show_file, const=edit_file, help=_("edit (or create) file"), ) @@ -863,7 +853,6 @@ def main(): '--remove', action='store_const', dest='action', - default=show_file, const=remove_file, help=_("erase file"), ) @@ -871,14 +860,12 @@ def main(): '-l', '--list', action='store_const', dest='action', - default=show_file, const=show_files, help=_("list files"), ) action_grp.add_argument( '-r', '--restore', action='store_const', dest='action', - default=show_file, const=restore_files, help=_("restore corrumpted files"), ) @@ -886,7 +873,6 @@ def main(): '--check-keys', action='store_const', dest='action', - default=show_file, const=my_check_keys, help=_("check keys"), ) @@ -894,7 +880,6 @@ def main(): '--update-keys', action='store_const', dest='action', - default=show_file, const=my_update_keys, help=_("update keys"), ) @@ -902,7 +887,6 @@ def main(): '--list-roles', action='store_const', dest='action', - default=show_file, const=show_roles, help=_("list existing roles"), ) @@ -910,27 +894,15 @@ def main(): '--list-servers', action='store_const', dest='action', - default=show_file, const=show_servers, help=_("list servers"), ) action_grp.add_argument( - '--recrypt-files', + '--recrypt', action='store_const', dest='action', - default=show_file, const=recrypt_files, - help=_("""Rechiffrer les mots de passe. - (Avec les mêmes rôles que ceux qu'ils avant. - Cela sert à mettre à jour les recipients pour qui un password est chiffré)"""), - ) - action_grp.add_argument( - '--strict-recrypt-files', - action='store_const', - dest='action', - default=show_file, const=lambda x: recrypt_files( - x, strict=True), - help=_("Rechiffrer les mots de passe (mode strict, voir --roles)"), + help=_("recrypt all files having a role listed in --roles"), ) action_grp.set_defaults(action=show_file) diff --git a/cpasswords/locale/fr/LC_MESSAGES/messages.po b/cpasswords/locale/fr/LC_MESSAGES/messages.po index 7d83e5a..5a0fd74 100644 --- a/cpasswords/locale/fr/LC_MESSAGES/messages.po +++ b/cpasswords/locale/fr/LC_MESSAGES/messages.po @@ -3,7 +3,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-04-14 11:00+0200\n" +"POT-Creation-Date: 2020-04-14 12:15+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -20,168 +20,152 @@ msgid "" "customize." msgstr "" "%s/clientconfig.ini n'a pas été trouvé.\n" -"Veuillez copier `docs/clientconfig.example.ini` à partir des sources et " -"le personnaliser." +"Veuillez copier `docs/clientconfig.example.ini` à partir des sources et le " +"personnaliser." -#: cpasswords/client.py:133 +#: cpasswords/client.py:131 #, python-format msgid "Writing to stdin: %s" msgstr "Écriture dans stdin: %s" -#: cpasswords/client.py:143 +#: cpasswords/client.py:141 #, python-format msgid "Wrong server return code %s, error is %s" msgstr "Mauvaise code de retour serveur %s, l'erreur est %s" -#: cpasswords/client.py:150 +#: cpasswords/client.py:148 msgid "Error while parsing JSON" msgstr "Erreur lors du parsing du JSON" -#: cpasswords/client.py:407 +#: cpasswords/client.py:405 msgid "Available files:" msgstr "Liste des fichiers disponibles :" -#: cpasswords/client.py:412 +#: cpasswords/client.py:410 #, python-format msgid "--Mes roles: %s" msgstr "" -#: cpasswords/client.py:417 +#: cpasswords/client.py:415 msgid "Fichier corrompus :" msgstr "" -#: cpasswords/client.py:427 +#: cpasswords/client.py:425 msgid "Liste des roles disponibles" msgstr "" -#: cpasswords/client.py:438 +#: cpasswords/client.py:436 msgid "Liste des serveurs disponibles" msgstr "" -#: cpasswords/client.py:453 +#: cpasswords/client.py:451 msgid "" "Appuyez sur Entrée pour récupérer le contenu précédent du presse papier." msgstr "" -#: cpasswords/client.py:514 +#: cpasswords/client.py:512 msgid "La clé a été mise dans l'agent ssh" msgstr "" -#: cpasswords/client.py:668 +#: cpasswords/client.py:666 msgid "" "Vérification que les clés sont valides (uid correspondant au login) et de " "confiance." msgstr "" -#: cpasswords/client.py:715 +#: cpasswords/client.py:713 #, python-format msgid "" "Vous vous apprêtez à rechiffrer les fichiers suivants :\n" "%s" msgstr "" -#: cpasswords/client.py:733 +#: cpasswords/client.py:731 msgid "Aucun fichier n'a besoin d'être rechiffré" msgstr "" -#: cpasswords/client.py:774 +#: cpasswords/client.py:772 msgid "You need to provide a filename with this command" msgstr "Un nom de fichier est nécessaire avec cette commande" -#: cpasswords/client.py:783 +#: cpasswords/client.py:781 msgid "Group passwords manager based on GPG." msgstr "Gestion de mots de passe partagés grâce à GPG." -#: cpasswords/client.py:789 +#: cpasswords/client.py:787 msgid "name of file to show or edit" msgstr "nom du fichier à lire ou éditer" -#: cpasswords/client.py:795 +#: cpasswords/client.py:793 msgid "verbose mode, multiple -v options increase verbosity" msgstr "mode verbeux, multiplier l'option -v pour augmenter" -#: cpasswords/client.py:801 +#: cpasswords/client.py:799 msgid "silent mode: hide errors, overrides verbosity" msgstr "mode silencieux: cache les erreurs, ignore la verbosité" -#: cpasswords/client.py:807 +#: cpasswords/client.py:805 msgid "select another server than DEFAULT" msgstr "sélectionne un autre server que DEFAULT" -#: cpasswords/client.py:814 +#: cpasswords/client.py:812 msgid "do not try to store password in clipboard" msgstr "n'essaie pas de stocker le mot de passe dans le presse papier" -#: cpasswords/client.py:820 +#: cpasswords/client.py:818 msgid "do not prompt confirmation" msgstr "ne pas demander confirmation" -#: cpasswords/client.py:827 +#: cpasswords/client.py:825 msgid "need --force, drop untrusted keys without confirmation." msgstr "" "avec --force, ignore les clés en lesquels on n'a pas confiance sans " "confirmation." -#: cpasswords/client.py:833 +#: cpasswords/client.py:831 msgid "" -"Liste de roles (séparés par des virgules). Par défaut, tous les\n" -" rôles en écriture (sauf pour l'édition, d'un fichier " -"existant).\n" -" Avec --edit: le fichier sera chiffré pour exactement ces " -"roles\n" -" Avec --(strict-)recrypt-files :\n" -" sert à sélectionnenr les fichiers à rechiffrer\n" -" * non-strict: tout fichier possédant un des rôles listé\n" -" * strict: tout fichier dont *tous* les rôles sont dans " -"la\n" -" liste\n" -" " +"specify for which roles to crypt (default to all roles, or do not change if " +"editing)" msgstr "" +"spécifier pour quels rôles chiffrer (défaut à tous les rôles, ou ne les " +"change pas si édition)" -#: cpasswords/client.py:852 +#: cpasswords/client.py:843 msgid "read file (default)" msgstr "lit le fichier (défaut)" -#: cpasswords/client.py:860 +#: cpasswords/client.py:850 msgid "edit (or create) file" msgstr "édite (ou crée) le fichier" -#: cpasswords/client.py:868 +#: cpasswords/client.py:857 msgid "erase file" msgstr "efface le fichier" -#: cpasswords/client.py:876 +#: cpasswords/client.py:864 msgid "list files" msgstr "liste les fichiers" -#: cpasswords/client.py:883 +#: cpasswords/client.py:870 msgid "restore corrumpted files" msgstr "restaure les fichiers corrompus" -#: cpasswords/client.py:891 +#: cpasswords/client.py:877 msgid "check keys" msgstr "vérifie les clés" -#: cpasswords/client.py:899 +#: cpasswords/client.py:884 msgid "update keys" msgstr "met à jour les clés" -#: cpasswords/client.py:907 +#: cpasswords/client.py:891 msgid "list existing roles" msgstr "liste les rôles existants" -#: cpasswords/client.py:915 +#: cpasswords/client.py:898 msgid "list servers" msgstr "liste les serveurs" -#: cpasswords/client.py:923 -msgid "" -"Rechiffrer les mots de passe.\n" -" (Avec les mêmes rôles que ceux qu'ils avant.\n" -" Cela sert à mettre à jour les recipients pour qui un " -"password est chiffré)" -msgstr "" - -#: cpasswords/client.py:933 -msgid "Rechiffrer les mots de passe (mode strict, voir --roles)" -msgstr "" +#: cpasswords/client.py:905 +msgid "recrypt all files having a role listed in --roles" +msgstr "rechiffre tous les fichiers ayant un rôle listé dans --roles" diff --git a/docs/update_locales.sh b/docs/update_locales.sh new file mode 100755 index 0000000..1253970 --- /dev/null +++ b/docs/update_locales.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# Execute docs/update_locales.sh from repo root +xgettext --from-code utf-8 -o messages.pot cpasswords/client.py +msgmerge --update cpasswords/locale/fr/LC_MESSAGES/messages.po messages.pot +rm messages.pot -- GitLab