From 802f667edf0c39f1951670700952084b2cd04c42 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Thu, 3 Jan 2019 17:19:40 +0100 Subject: [PATCH] Translating lib/webhooks/r10k.py --- lib/webhooks/base_app.py | 7 +- lib/webhooks/r10k.py | 166 +++++++++--------- .../LC_MESSAGES/puppetmaster_webhooks.po | 85 ++++++++- .../LC_MESSAGES/puppetmaster_webhooks.po | 83 ++++++++- locale/puppetmaster_webhooks.pot | 85 ++++++++- r10k_hook.py | 14 +- 6 files changed, 332 insertions(+), 108 deletions(-) diff --git a/lib/webhooks/base_app.py b/lib/webhooks/base_app.py index 1c7c8f8..217789a 100644 --- a/lib/webhooks/base_app.py +++ b/lib/webhooks/base_app.py @@ -570,12 +570,9 @@ class BaseHookApp(BaseApplication): # ------------------------------------------------------------------------- def search_curl_bin(self): - searcher = BaseHandler( - appname=self.appname, verbose=self.verbose, base_dir=self.base_dir) - - cmd = searcher.get_cmd('curl') - del searcher + cmd = self.get_cmd('curl') if not cmd: + LOG.error(_("Command {!r} not found.").format('curl')) sys.exit(9) self.curl_bin = cmd return diff --git a/lib/webhooks/r10k.py b/lib/webhooks/r10k.py index 3a59b6a..f890671 100644 --- a/lib/webhooks/r10k.py +++ b/lib/webhooks/r10k.py @@ -17,6 +17,7 @@ import locale import pipes import urllib.parse import warnings +import pathlib # Third party modules import requests @@ -29,8 +30,13 @@ from . import __version__ from .base_app import BaseHookApp +from .xlate import XLATOR + LOG = logging.getLogger(__name__) +_ = XLATOR.gettext +ngettext = XLATOR.ngettext + # ============================================================================= class R10kHookApp(BaseHookApp): @@ -39,14 +45,12 @@ class R10kHookApp(BaseHookApp): """ # ------------------------------------------------------------------------- - def __init__(self, appname=None, verbose=0, version=__version__): + def __init__(self, appname=None, base_dir=None, verbose=0, version=__version__): """Constructor.""" self.r10k_bin = None self.puppet_bin = None - description = textwrap.dedent('''\ - Receives push events as JSON-Data and deploys it with r10k. - ''').strip() + description = _("Receives push events as JSON-Data and deploys it with r10k.") self.locale = 'de_DE.utf8' self.http_timeout = 30 @@ -54,13 +58,13 @@ class R10kHookApp(BaseHookApp): self.puppetmaster_host = 'puppetmaster01.pixelpark.com' self.puppetmaster_api_port = 8140 self.puppetmaster_api_path = '/puppet-admin-api/v1' - self.puppetmaster_ssl_dir = os.sep + os.path.join( - 'var', 'lib', 'puppet', 'ssl') + self.puppetmaster_ssl_dir = pathlib.Path(os.sep) / 'var' / 'lib' / 'puppet' / 'ssl' self.user_agent = 'pp-webhook-client/' + __version__ super(R10kHookApp, self).__init__( - appname=appname, verbose=verbose, version=version, description=description) + appname=appname, verbose=verbose, base_dir=base_dir, + version=version, description=description) # ------------------------------------------------------------------------- def post_init(self): @@ -91,12 +95,9 @@ class R10kHookApp(BaseHookApp): # ------------------------------------------------------------------------- def search_puppet_bin(self): - searcher = BaseHandler( - appname=self.appname, verbose=self.verbose, base_dir=self.base_dir) - - cmd = searcher.get_cmd('puppet') - del searcher + cmd = self.get_cmd('puppet') if not cmd: + LOG.error(_("Command {!r} not found.").format('puppet')) sys.exit(9) self.puppet_bin = cmd return @@ -104,52 +105,58 @@ class R10kHookApp(BaseHookApp): # ------------------------------------------------------------------------- def search_r10k_bin(self): - searcher = BaseHandler( - appname=self.appname, verbose=self.verbose, base_dir=self.base_dir) - - cmd = searcher.get_cmd('r10k') - del searcher + cmd = self.get_cmd('r10k') if not cmd: + LOG.error(_("Command {!r} not found.").format('r10k')) sys.exit(9) self.r10k_bin = cmd # ------------------------------------------------------------------------- def check_cert_files(self): - if not os.path.isabs(self.puppetmaster_ssl_dir): - LOG.error("Puppetmaster SSL directory {!r} is not an absolute path name.".format( - self.puppetmaster_ssl_dir)) + if not self.puppetmaster_ssl_dir.is_absolute(): + LOG.error(_("Puppetmaster SSL directory {!r} is not an absolute path name.").format( + str(self.puppetmaster_ssl_dir))) sys.exit(10) - pdir = os.path.dirname(self.puppetmaster_ssl_dir) - if not os.path.isdir(pdir): - LOG.error("Directory {!r} does not exists.".format(pdir)) + pdir = self.puppetmaster_ssl_dir.parent + if self.verbose > 2: + LOG.debug("Checking directory {!r} ...".format(str(pdir))) + if not pdir.is_dir(): + LOG.error(_("Directory {!r} does not exists.").format(str(pdir))) sys.exit(10) - - if not os.access(pdir, os.R_OK): - LOG.debug(( + if not os.access(str(pdir), os.R_OK): + LOG.debug(_( "Directory {!r} is read protected, " - "cannot check existence of cert files.").format(pdir)) + "cannot check existence of cert files.").format(str(pdir))) return - if not os.path.isdir(self.puppetmaster_ssl_dir): - LOG.error("Puppetmaster SSL directory {!r} does not exists.".format( - self.puppetmaster_ssl_dir)) + if self.verbose > 2: + LOG.debug("Checking directory {!r} ...".format(str(self.puppetmaster_ssl_dir))) + if not self.puppetmaster_ssl_dir.is_dir(): + LOG.error(_("Puppetmaster SSL directory {!r} does not exists.").format( + str(self.puppetmaster_ssl_dir))) sys.exit(10) + if not os.access(str(self.puppetmaster_ssl_dir), os.R_OK): + LOG.debug(_( + "Directory {!r} is read protected, " + "cannot check existence of cert files.").format(str(self.puppetmaster_ssl_dir))) + return rel_paths = [] - rel_paths.append(os.path.join('certs', self.puppetmaster_host + '.pem')) - rel_paths.append(os.path.join('private_keys', self.puppetmaster_host + '.pem')) + bname = self.puppetmaster_host + '.pem' + rel_paths.append(pathlib.Path('certs') / bname) + rel_paths.append(pathlib.Path('private_keys') / bname) for path in rel_paths: - abs_path = os.path.join(self.puppetmaster_ssl_dir, path) + abs_path = self.puppetmaster_ssl_dir / path if self.verbose > 2: - LOG.debug("Checking file {!r} ...".format(abs_path)) - if not os.path.exists(abs_path): - LOG.error("File {!r} does not exists.".format(abs_path)) + LOG.debug("Checking file {!r} ...".format(str(abs_path))) + if not abs_path.exists(): + LOG.error(_("File {!r} does not exists.").format(str(abs_path))) sys.exit(10) - if not os.access(abs_path, os.R_OK): - LOG.error("File {!r} is not readable.".format(abs_path)) + if not os.access(str(abs_path), os.R_OK): + LOG.error(_("File {!r} is not readable.").format(str(abs_path))) sys.exit(10) # ------------------------------------------------------------------------- @@ -168,13 +175,13 @@ class R10kHookApp(BaseHookApp): try: self.puppetmaster_api_port = int(ppm_cfg['api_port']) except Exception as e: - msg = "Invalid port {p!r} for puppetmaster API in {f!r} found: {e}".format( + msg = _("Invalid port {p!r} for puppetmaster API in {f!r} found: {e}").format( p=ppm_cfg['api_port'], f=yaml_file, e=e) self.error_data.append(msg) if 'api_path' in ppm_cfg and ppm_cfg['api_path']: self.puppetmaster_api_path = ppm_cfg['api_path'] if 'ssl_dir' in ppm_cfg and ppm_cfg['ssl_dir']: - self.puppetmaster_ssl_dir = ppm_cfg['ssl_dir'] + self.puppetmaster_ssl_dir = pathlib.Path(ppm_cfg['ssl_dir']) # ------------------------------------------------------------------------- def pre_run_hook(self): @@ -185,7 +192,7 @@ class R10kHookApp(BaseHookApp): cur_loc = locale.getlocale() cur_lang = os.environ.get('LANG', None) if self.verbose > 1: - LOG.debug("Current locale is: {lo!r}, current LANG is {la!r}.".format( + LOG.debug(_("Current locale is: {lo!r}, current LANG is {la!r}.").format( lo=cur_loc, la=cur_lang)) LOG.debug("Setting locale and LANG to: {!r}.".format(self.locale)) @@ -199,13 +206,12 @@ class R10kHookApp(BaseHookApp): """Main routine.""" if not self.exec_r10k(): - LOG.warn("Executing {!r} was not successful.".format(self.r10k_bin)) + LOG.warn(_("Executing {!r} was not successful.").format(str(self.r10k_bin))) return if not self.generate_puppet_types(): - msg = "'{c} generate types --environment {e}' was not successful.".format( - self.puppet_bin, self.ref) - LOG.warn(msg) + what = '{c} generate types --environment {e}'.format(c=self.puppet_bin, e=self.ref) + LOG.warn(_("{!r} was not successful.").format(what)) return return self.del_env_cache() @@ -214,30 +220,28 @@ class R10kHookApp(BaseHookApp): def del_env_cache(self): if self.env_dir is None: - raise RuntimeError("No environment defined.") + raise RuntimeError(_("No environment defined.")) - LOG.debug("Searching for environment directory {!r} ...".format(self.env_dir)) - if not os.path.isdir(self.env_dir): - LOG.info("Environment directory {!r} does not exists.".format(self.env_dir)) + LOG.debug("Searching for environment directory {!r} ...".format(str(self.env_dir))) + if not self.env_dir.is_dir(): + LOG.info(_("Environment directory {!r} does not exists.").format(str(self.env_dir))) return - LOG.info("Clearing environment cache for env {!r} on {!r}.".format( - self.ref, self.puppetmaster_host)) + LOG.info(_("Clearing environment cache for environment {e!r} on {h!r}.").format( + e=self.ref, h=self.puppetmaster_host)) + + bname = self.puppetmaster_host + '.pem' + key_file = self.puppetmaster_ssl_dir / 'private_keys' / bname + cert_file = self.puppetmaster_ssl_dir / 'certs' / bname + ca_file = self.puppetmaster_ssl_dir / 'certs' /'ca.pem' - key_file = os.path.join( - self.puppetmaster_ssl_dir, 'private_keys', self.puppetmaster_host + '.pem') - cert_file = os.path.join( - self.puppetmaster_ssl_dir, 'certs', self.puppetmaster_host + '.pem') - cert = (cert_file, key_file) + cert = (str(cert_file), str(key_file)) session = requests.Session() headers = dict() headers.update({'User-Agent': self.user_agent}) headers.update({'Content-Type': 'text/plain'}) - ca_file = os.path.join( - self.puppetmaster_ssl_dir, 'certs', 'ca.pem') - path = ( self.puppetmaster_api_path + '/environment-cache?environment=' + urllib.parse.quote(self.ref)) @@ -246,14 +250,14 @@ class R10kHookApp(BaseHookApp): LOG.debug("Requesting DELETE from {} ...".format(url)) if self.simulate: - LOG.info("Simulation mode, don't requesting URL.") + LOG.info(_("Simulation mode, don't requesting URL.")) return with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") response = session.request( 'DELETE', url, headers=headers, timeout=self.http_timeout, - cert=cert, verify=ca_file) + cert=cert, verify=str(ca_file)) if w: warn_class = w[-1].category.__name__ warn_msg = '{}: {}'.format( @@ -266,18 +270,18 @@ class R10kHookApp(BaseHookApp): if response.ok: LOG.debug("Got status code: {}.".format(response.status_code)) if response.text: - msg = "Output:\n{}".format(response.text) + msg = _("Output:") + '\n' + response.text else: - msg = "No output." + msg = _("No output.") LOG.info(msg) self.print_out(msg) return - msg = "Got status code: {}.".format(response.status_code) + msg = _("Got status code: {}.").format(response.status_code) if response.text: - msg += "\nOutput:\n{}".format(response.text) + msg += "\n" + _("Output:") + '\n' + response.text else: - msg += " No output." + msg += " " + _("No output.") LOG.warn(msg) self.print_out(msg) return @@ -287,13 +291,13 @@ class R10kHookApp(BaseHookApp): """Generates definitions for custom resource types using Puppet code for the given environment.""" - LOG.info("Generating Puppet types for env {!r} on {!r}.".format( - self.ref, self.puppetmaster_host)) + LOG.info(_("Generating Puppet types for environment {e!r} on {h!r}.").format( + e=self.ref, h=self.puppetmaster_host)) res = True cmd = [ - self.puppet_bin, 'generate', 'types', + str(self.puppet_bin), 'generate', 'types', '--environment', self.ref, '--color', 'false', ] @@ -305,15 +309,15 @@ class R10kHookApp(BaseHookApp): proc = self.handler.call(cmd, sudo=self.do_sudo) if proc.stdout: - msg = "Output:\n{}".format(proc.stdout) + msg = _("Output:") + '\n' + proc.stdout self.print_out(msg) else: - LOG.debug("No output.") + LOG.debug(_("No output.")) if proc.stderr: cmd_str = ' '.join(map(lambda x: pipes.quote(x), proc.args)) - msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=proc.stderr) - msg_rc = "Returncode was {}.".format(proc.returncode) + msg = _("Error messages on {c!r}:\n{e}").format(c=cmd_str, e=proc.stderr) + msg_rc = _("Returncode was {}.").format(proc.returncode) self.print_out(msg) if proc.returncode: self.print_out(msg_rc) @@ -326,8 +330,8 @@ class R10kHookApp(BaseHookApp): # ------------------------------------------------------------------------- def exec_r10k(self): - LOG.info("Deploying r10k environment {!r} on {!r}.".format( - self.ref, self.puppetmaster_host)) + LOG.info(_("Deploying r10k environment {e!r} on {h!r}.").format( + e=self.ref, h=self.puppetmaster_host)) res = True @@ -341,22 +345,22 @@ class R10kHookApp(BaseHookApp): r10k_loglevel = 'debug' cmd = [ - self.r10k_bin, 'deploy', 'environment', + str(self.r10k_bin), 'deploy', 'environment', self.ref, '--puppetfile', '--verbose', r10k_loglevel ] proc = self.handler.call(cmd, sudo=self.do_sudo) if proc.stdout: - msg = "Output:\n{}".format(proc.stdout) + msg = _("Output:") + '\n' + proc.stdout self.print_out(msg) else: - LOG.debug("No output.") + LOG.debug(_("No output.")) - if stderrdata: + if proc.stderr: cmd_str = ' '.join(map(lambda x: pipes.quote(x), proc.args)) - msg = "Error messages on '{c}':\n{e}".format(c=cmd_str, e=proc.stderr) - msg_rc = "Returncode was {}.".format(proc.returncode) + msg = _("Error messages on {c!r}:\n{e}").format(c=cmd_str, e=proc.stderr) + msg_rc = _("Returncode was {}.").format(proc.returncode) self.print_out(msg) if proc.returncode: self.print_out(msg_rc) diff --git a/locale/de_DE/LC_MESSAGES/puppetmaster_webhooks.po b/locale/de_DE/LC_MESSAGES/puppetmaster_webhooks.po index ed41243..90cfae5 100644 --- a/locale/de_DE/LC_MESSAGES/puppetmaster_webhooks.po +++ b/locale/de_DE/LC_MESSAGES/puppetmaster_webhooks.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: puppetmaster_webhooks 1.3.1\n" "Report-Msgid-Bugs-To: frank.brehm@pixelpark.com\n" -"POT-Creation-Date: 2019-01-03 12:21+0100\n" -"PO-Revision-Date: 2019-01-03 12:25+0100\n" +"POT-Creation-Date: 2019-01-03 14:03+0100\n" +"PO-Revision-Date: 2019-01-03 14:12+0100\n" "Last-Translator: Frank Brehm \n" "Language: de_DE\n" "Language-Team: de_DE \n" @@ -260,11 +260,12 @@ msgstr "Das übergeordnete Verzeichnis {d!r} des Projekts {p!r} existiert nicht. msgid "Path for parent directory {d!r} for project {p!r} is not a directory." msgstr "Der Pfad zum übergeordneten Verzeichnis {d!r} des Projekts {p!r} ist kein Verzeichnis." -#: lib/webhooks/deploy.py:241 +#: lib/webhooks/deploy.py:241 lib/webhooks/r10k.py:263 lib/webhooks/r10k.py:272 +#: lib/webhooks/r10k.py:302 lib/webhooks/r10k.py:345 msgid "Output:" msgstr "Ausgabe:" -#: lib/webhooks/deploy.py:248 +#: lib/webhooks/deploy.py:248 lib/webhooks/r10k.py:309 lib/webhooks/r10k.py:352 msgid "" "Error messages on {c!r}:\n" "{e}" @@ -272,7 +273,7 @@ msgstr "" "Fehlermeldungen von {c!r}:\n" "{e}" -#: lib/webhooks/deploy.py:249 +#: lib/webhooks/deploy.py:249 lib/webhooks/r10k.py:310 lib/webhooks/r10k.py:353 msgid "Returncode was {}." msgstr "Rückgabewert war {}." @@ -316,7 +317,7 @@ msgstr "Lese Metadaten-Dateien von Umgebung {!r} ⋯" msgid "Got no module info from directory {!r}." msgstr "Keine Modul-Informationen aus dem Verzeichnis {!r} erhalten." -#: lib/webhooks/get_forge_modules.py:296 +#: lib/webhooks/get_forge_modules.py:296 lib/webhooks/r10k.py:122 msgid "Directory {!r} does not exists." msgstr "Das Verzeichnis {!r} existiert nicht." @@ -544,6 +545,78 @@ msgstr "Das Puppetfile {!r} existiert nicht." msgid "Puppetfile {!r} is not readable." msgstr "Das Puppetfile {!r} kann nicht gelesen werden." +#: lib/webhooks/r10k.py:53 +msgid "Receives push events as JSON-Data and deploys it with r10k." +msgstr "Erhält Push-Ereignisse als JSON-Daten und verteilt diese mittels r10k." + +#: lib/webhooks/r10k.py:116 +msgid "Puppetmaster SSL directory {!r} is not an absolute path name." +msgstr "Das Puppetmaster-SSL-Verzeichnis {!r} ist kein absoluter Pfad." + +#: lib/webhooks/r10k.py:126 +msgid "Directory {!r} is read protected, cannot check existence of cert files." +msgstr "Das Verzeichnis {!r} ist lesegeschützt, kann deshalb die Existenz der Zertifikats-Dateien nicht überprüfen." + +#: lib/webhooks/r10k.py:132 +msgid "Puppetmaster SSL directory {!r} does not exists." +msgstr "Das Puppetmaster-SSL-Verzeichnis {!r} existiert nicht." + +#: lib/webhooks/r10k.py:146 +msgid "File {!r} does not exists." +msgstr "Die Datei {!r} existiert nicht." + +#: lib/webhooks/r10k.py:149 +msgid "File {!r} is not readable." +msgstr "Die Datei {!r} kann nicht gelesen werden." + +#: lib/webhooks/r10k.py:168 +msgid "Invalid port {p!r} for puppetmaster API in {f!r} found: {e}" +msgstr "Ungültige Portnummer {p!r} für die Puppetmaster-API in {f!r} gefunden: {e}" + +#: lib/webhooks/r10k.py:185 +msgid "Current locale is: {lo!r}, current LANG is {la!r}." +msgstr "Aktuelles Gebietsschema ist: {lo!r}, die aktuelle Sprache ist: {la!r}." + +#: lib/webhooks/r10k.py:199 +msgid "Executing {!r} was not successful." +msgstr "Die Ausführung von {!r} war nicht erfolgreich." + +#: lib/webhooks/r10k.py:204 +msgid "{!r} was not successful." +msgstr "{!r} war nicht erfolgreich." + +#: lib/webhooks/r10k.py:213 +msgid "No environment defined." +msgstr "Keine Umgebung definiert." + +#: lib/webhooks/r10k.py:217 +msgid "Environment directory {!r} does not exists." +msgstr "Das Umgebungs-Verzeichnis {!r} existiert nicht." + +#: lib/webhooks/r10k.py:220 +msgid "Clearing environment cache for environment {e!r} on {h!r}." +msgstr "Lösche Umgebungs-Cache für die Umgebung {e!r} auf {h!r}." + +#: lib/webhooks/r10k.py:243 +msgid "Simulation mode, don't requesting URL." +msgstr "Simulations-Modus, frage keine URL ab." + +#: lib/webhooks/r10k.py:265 lib/webhooks/r10k.py:274 lib/webhooks/r10k.py:305 lib/webhooks/r10k.py:348 +msgid "No output." +msgstr "Keine Ausgabe." + +#: lib/webhooks/r10k.py:270 +msgid "Got status code: {}." +msgstr "Erhaltener Statuscode: {}" + +#: lib/webhooks/r10k.py:284 +msgid "Generating Puppet types for environment {e!r} on {h!r}." +msgstr "Generiere Puppet-Typen für die Umgebung {e!r} auf {h!r}." + +#: lib/webhooks/r10k.py:323 +msgid "Deploying r10k environment {e!r} on {h!r}." +msgstr "Rolle r10k-Umgebung {e!r} auf {h!r} aus." + #: lib/webhooks/show_modules.py:59 msgid "Returns a list with all used Puppet modules." msgstr "Gibt eine Liste mit allen Puppet-Modulen zurück." diff --git a/locale/en_US/LC_MESSAGES/puppetmaster_webhooks.po b/locale/en_US/LC_MESSAGES/puppetmaster_webhooks.po index 8aaeffe..92c98ae 100644 --- a/locale/en_US/LC_MESSAGES/puppetmaster_webhooks.po +++ b/locale/en_US/LC_MESSAGES/puppetmaster_webhooks.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: puppetmaster_webhooks 1.3.1\n" "Report-Msgid-Bugs-To: frank.brehm@pixelpark.com\n" -"POT-Creation-Date: 2019-01-03 12:21+0100\n" +"POT-Creation-Date: 2019-01-03 14:03+0100\n" "PO-Revision-Date: 2018-12-28 09:57+0100\n" "Last-Translator: FULL NAME \n" "Language: en_US\n" @@ -248,17 +248,18 @@ msgstr "" msgid "Path for parent directory {d!r} for project {p!r} is not a directory." msgstr "" -#: lib/webhooks/deploy.py:241 +#: lib/webhooks/deploy.py:241 lib/webhooks/r10k.py:263 lib/webhooks/r10k.py:272 +#: lib/webhooks/r10k.py:302 lib/webhooks/r10k.py:345 msgid "Output:" msgstr "" -#: lib/webhooks/deploy.py:248 +#: lib/webhooks/deploy.py:248 lib/webhooks/r10k.py:309 lib/webhooks/r10k.py:352 msgid "" "Error messages on {c!r}:\n" "{e}" msgstr "" -#: lib/webhooks/deploy.py:249 +#: lib/webhooks/deploy.py:249 lib/webhooks/r10k.py:310 lib/webhooks/r10k.py:353 msgid "Returncode was {}." msgstr "" @@ -300,7 +301,7 @@ msgstr "" msgid "Got no module info from directory {!r}." msgstr "" -#: lib/webhooks/get_forge_modules.py:296 +#: lib/webhooks/get_forge_modules.py:296 lib/webhooks/r10k.py:122 msgid "Directory {!r} does not exists." msgstr "" @@ -520,6 +521,78 @@ msgstr "" msgid "Puppetfile {!r} is not readable." msgstr "" +#: lib/webhooks/r10k.py:53 +msgid "Receives push events as JSON-Data and deploys it with r10k." +msgstr "" + +#: lib/webhooks/r10k.py:116 +msgid "Puppetmaster SSL directory {!r} is not an absolute path name." +msgstr "" + +#: lib/webhooks/r10k.py:126 +msgid "Directory {!r} is read protected, cannot check existence of cert files." +msgstr "" + +#: lib/webhooks/r10k.py:132 +msgid "Puppetmaster SSL directory {!r} does not exists." +msgstr "" + +#: lib/webhooks/r10k.py:146 +msgid "File {!r} does not exists." +msgstr "" + +#: lib/webhooks/r10k.py:149 +msgid "File {!r} is not readable." +msgstr "" + +#: lib/webhooks/r10k.py:168 +msgid "Invalid port {p!r} for puppetmaster API in {f!r} found: {e}" +msgstr "" + +#: lib/webhooks/r10k.py:185 +msgid "Current locale is: {lo!r}, current LANG is {la!r}." +msgstr "" + +#: lib/webhooks/r10k.py:199 +msgid "Executing {!r} was not successful." +msgstr "" + +#: lib/webhooks/r10k.py:204 +msgid "{!r} was not successful." +msgstr "" + +#: lib/webhooks/r10k.py:213 +msgid "No environment defined." +msgstr "" + +#: lib/webhooks/r10k.py:217 +msgid "Environment directory {!r} does not exists." +msgstr "" + +#: lib/webhooks/r10k.py:220 +msgid "Clearing environment cache for environment {e!r} on {h!r}." +msgstr "" + +#: lib/webhooks/r10k.py:243 +msgid "Simulation mode, don't requesting URL." +msgstr "" + +#: lib/webhooks/r10k.py:265 lib/webhooks/r10k.py:274 lib/webhooks/r10k.py:305 lib/webhooks/r10k.py:348 +msgid "No output." +msgstr "" + +#: lib/webhooks/r10k.py:270 +msgid "Got status code: {}." +msgstr "" + +#: lib/webhooks/r10k.py:284 +msgid "Generating Puppet types for environment {e!r} on {h!r}." +msgstr "" + +#: lib/webhooks/r10k.py:323 +msgid "Deploying r10k environment {e!r} on {h!r}." +msgstr "" + #: lib/webhooks/show_modules.py:59 msgid "Returns a list with all used Puppet modules." msgstr "" diff --git a/locale/puppetmaster_webhooks.pot b/locale/puppetmaster_webhooks.pot index 333d8e1..84bcf40 100644 --- a/locale/puppetmaster_webhooks.pot +++ b/locale/puppetmaster_webhooks.pot @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: puppetmaster_webhooks 1.4.4\n" +"Project-Id-Version: puppetmaster_webhooks 1.4.5\n" "Report-Msgid-Bugs-To: frank.brehm@pixelpark.com\n" -"POT-Creation-Date: 2019-01-03 12:21+0100\n" +"POT-Creation-Date: 2019-01-03 14:03+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -247,17 +247,18 @@ msgstr "" msgid "Path for parent directory {d!r} for project {p!r} is not a directory." msgstr "" -#: lib/webhooks/deploy.py:241 +#: lib/webhooks/deploy.py:241 lib/webhooks/r10k.py:263 lib/webhooks/r10k.py:272 +#: lib/webhooks/r10k.py:302 lib/webhooks/r10k.py:345 msgid "Output:" msgstr "" -#: lib/webhooks/deploy.py:248 +#: lib/webhooks/deploy.py:248 lib/webhooks/r10k.py:309 lib/webhooks/r10k.py:352 msgid "" "Error messages on {c!r}:\n" "{e}" msgstr "" -#: lib/webhooks/deploy.py:249 +#: lib/webhooks/deploy.py:249 lib/webhooks/r10k.py:310 lib/webhooks/r10k.py:353 msgid "Returncode was {}." msgstr "" @@ -299,7 +300,7 @@ msgstr "" msgid "Got no module info from directory {!r}." msgstr "" -#: lib/webhooks/get_forge_modules.py:296 +#: lib/webhooks/get_forge_modules.py:296 lib/webhooks/r10k.py:122 msgid "Directory {!r} does not exists." msgstr "" @@ -519,6 +520,78 @@ msgstr "" msgid "Puppetfile {!r} is not readable." msgstr "" +#: lib/webhooks/r10k.py:53 +msgid "Receives push events as JSON-Data and deploys it with r10k." +msgstr "" + +#: lib/webhooks/r10k.py:116 +msgid "Puppetmaster SSL directory {!r} is not an absolute path name." +msgstr "" + +#: lib/webhooks/r10k.py:126 +msgid "Directory {!r} is read protected, cannot check existence of cert files." +msgstr "" + +#: lib/webhooks/r10k.py:132 +msgid "Puppetmaster SSL directory {!r} does not exists." +msgstr "" + +#: lib/webhooks/r10k.py:146 +msgid "File {!r} does not exists." +msgstr "" + +#: lib/webhooks/r10k.py:149 +msgid "File {!r} is not readable." +msgstr "" + +#: lib/webhooks/r10k.py:168 +msgid "Invalid port {p!r} for puppetmaster API in {f!r} found: {e}" +msgstr "" + +#: lib/webhooks/r10k.py:185 +msgid "Current locale is: {lo!r}, current LANG is {la!r}." +msgstr "" + +#: lib/webhooks/r10k.py:199 +msgid "Executing {!r} was not successful." +msgstr "" + +#: lib/webhooks/r10k.py:204 +msgid "{!r} was not successful." +msgstr "" + +#: lib/webhooks/r10k.py:213 +msgid "No environment defined." +msgstr "" + +#: lib/webhooks/r10k.py:217 +msgid "Environment directory {!r} does not exists." +msgstr "" + +#: lib/webhooks/r10k.py:220 +msgid "Clearing environment cache for environment {e!r} on {h!r}." +msgstr "" + +#: lib/webhooks/r10k.py:243 +msgid "Simulation mode, don't requesting URL." +msgstr "" + +#: lib/webhooks/r10k.py:265 lib/webhooks/r10k.py:274 lib/webhooks/r10k.py:305 lib/webhooks/r10k.py:348 +msgid "No output." +msgstr "" + +#: lib/webhooks/r10k.py:270 +msgid "Got status code: {}." +msgstr "" + +#: lib/webhooks/r10k.py:284 +msgid "Generating Puppet types for environment {e!r} on {h!r}." +msgstr "" + +#: lib/webhooks/r10k.py:323 +msgid "Deploying r10k environment {e!r} on {h!r}." +msgstr "" + #: lib/webhooks/show_modules.py:59 msgid "Returns a list with all used Puppet modules." msgstr "" diff --git a/r10k_hook.py b/r10k_hook.py index a8baaaf..f565482 100755 --- a/r10k_hook.py +++ b/r10k_hook.py @@ -6,18 +6,22 @@ import os import sys import logging +from pathlib import Path + # own modules: -basedir = os.path.abspath(os.path.dirname(__file__)) -libdir = os.path.join(basedir, 'lib') +my_path = Path(__file__) +my_real_path = my_path.resolve() +base_dir = my_real_path.parent +libdir = base_dir.joinpath('lib') -sys.path.insert(0, libdir) +sys.path.insert(0, str(libdir)) from webhooks.r10k import R10kHookApp # noqa -MY_APPNAME = 'r10k-hook' +MY_APPNAME = my_path.stem.replace('_', '-') LOG = logging.getLogger(MY_APPNAME) -app = R10kHookApp(appname=MY_APPNAME) +app = R10kHookApp(appname=MY_APPNAME, base_dir=base_dir) if app.verbose > 2: LOG.debug("{c} object:\n{o}".format(c=app.__class__.__name__, o=app)) -- 2.39.5