From: Frank Brehm Date: Mon, 29 Nov 2021 14:04:05 +0000 (+0100) Subject: Finishing adding translation markers to lib/pp_admintools/pidfile.py X-Git-Tag: 0.4.1~5^2~18^2~3 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=e504f7e5e98bfc17a468d58387e6206aeb9bec72;p=pixelpark%2Fpp-admin-tools.git Finishing adding translation markers to lib/pp_admintools/pidfile.py --- diff --git a/lib/pp_admintools/deploy_zones_from_pdns.py b/lib/pp_admintools/deploy_zones_from_pdns.py index 17401b0..f6a665f 100644 --- a/lib/pp_admintools/deploy_zones_from_pdns.py +++ b/lib/pp_admintools/deploy_zones_from_pdns.py @@ -37,7 +37,7 @@ from .pidfile import PidFileError, PidFile from .xlate import XLATOR -__version__ = '0.6.2' +__version__ = '0.6.3' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -594,6 +594,7 @@ class PpDeployZonesApp(PpPDNSApplication): what=_("Target file"), f=file_tgt) raise PpDeployZonesError(msg) + # Reading source file content_src = '' if self.verbose > 2: LOG.debug(_("Reading {!r} ...").format(file_src)) @@ -609,9 +610,10 @@ class PpDeployZonesApp(PpPDNSApplication): if self.verbose > 3: LOG.debug(_("Cleaned version of {!r}:").format(file_src) + '\n' + '\n'.join(lines_src)) + # Reading target file content_tgt = '' if self.verbose > 2: - LOG.debug("Reading {!r} ...".format(file_tgt)) + LOG.debug(_("Reading {!r} ...").format(file_tgt)) with open(file_tgt, 'r', **self.open_args) as fh: content_tgt = fh.read() lines_str_tgt = self.re_block_comment.sub('', content_tgt) @@ -622,22 +624,21 @@ class PpDeployZonesApp(PpPDNSApplication): if line: lines_tgt.append(line) if self.verbose > 3: - LOG.debug("Cleaned version of {!r}:\n{}".format( - file_tgt, '\n'.join(lines_tgt))) + LOG.debug(_("Cleaned version of {!r}:").format(file_tgt) + '\n' + '\n'.join(lines_tgt)) if len(lines_src) != len(lines_tgt): - LOG.debug(( - "Source file {!r} has different number essential lines ({}) than " - "the target file {!r} ({} lines).").format( - file_src, len(lines_src), file_tgt, len(lines_tgt))) + LOG.debug(_( + "Source file {sf!r} has different number essential lines ({sl}) than " + "the target file {tf!r} ({tl} lines).").format( + sf=file_src, sl=len(lines_src), tf=file_tgt, tl=len(lines_tgt))) return False i = 0 while i < len(lines_src): if lines_src[i] != lines_tgt[i]: - LOG.debug(( - "Source file {!r} has a different content than " - "the target file {!r}.").format(file_src, lines_tgt)) + LOG.debug(_( + "Source file {sf!r} has a different content than " + "the target file {tf!r}.").format(sf=file_src, tf=lines_tgt)) return False i += 1 @@ -647,10 +648,10 @@ class PpDeployZonesApp(PpPDNSApplication): def replace_configfiles(self): if not self.files2replace: - LOG.debug("No replacement of any config files necessary.") + LOG.debug(_("No replacement of any config files necessary.")) return - LOG.debug("Start replacing of config files ...") + LOG.debug(_("Start replacing of config files ...")) for tgt_file in self.files2replace.keys(): @@ -658,42 +659,42 @@ class PpDeployZonesApp(PpPDNSApplication): if os.path.exists(tgt_file): self.moved_files[tgt_file] = backup_file - LOG.info("Copying {!r} => {!r} ...".format(tgt_file, backup_file)) + LOG.info(_("Copying {frm!r} => {to!r} ...").format(frm=tgt_file, to=backup_file)) if not self.simulate: shutil.copy2(tgt_file, backup_file) if self.verbose > 1: - LOG.debug("All backuped config files:\n{}".format(pp(self.moved_files))) + LOG.debug(_("All backuped config files:") + '\n' + pp(self.moved_files)) for tgt_file in self.files2replace.keys(): src_file = self.files2replace[tgt_file] - LOG.info("Copying {!r} => {!r} ...".format(src_file, tgt_file)) + LOG.info(_("Copying {frm!r} => {to!r} ...").format(frm=src_file, to=tgt_file)) if not self.simulate: shutil.copy2(src_file, tgt_file) # ------------------------------------------------------------------------- def restore_configfiles(self): - LOG.error("Restoring of original config files because of an exception.") + LOG.error(_("Restoring of original config files because of an exception.")) for tgt_file in self.moved_files.keys(): backup_file = self.moved_files[tgt_file] - LOG.info("Moving {!r} => {!r} ...".format(backup_file, tgt_file)) + LOG.info(_("Moving {frm!r} => {to!r} ...").format(frm=backup_file, to=tgt_file)) if not self.simulate: if os.path.exists(backup_file): os.rename(backup_file, tgt_file) else: - LOG.error("Could not find backup file {!r}.".format(backup_file)) + LOG.error(_("Could not find backup file {!r}.").format(backup_file)) # ------------------------------------------------------------------------- def check_namedconf(self): - LOG.info("Checking syntax correctness of named.conf ...") + LOG.info(_("Checking syntax correctness of named.conf ...")) cmd = shlex.split(self.cmd_checkconf) if 'named-checkconf' in self.cmd_checkconf and self.verbose > 2: cmd.append('-p') cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd)) - LOG.debug("Executing: {}".format(cmd_str)) + LOG.debug(_("Executing: {}").format(cmd_str)) std_out = None std_err = None @@ -707,13 +708,11 @@ class PpDeployZonesApp(PpPDNSApplication): std_out, std_err = proc.communicate() ret_val = proc.wait() - LOG.debug("Return value: {!r}".format(ret_val)) + LOG.debug(_("Return value: {!r}").format(ret_val)) if std_out and std_out.strip(): - s = to_str(std_out.strip()) - LOG.warn("Output on STDOUT: {}".format(s)) + LOG.warn(_("Output on {}").format('STDOUT') + ' ' + to_str(std_out.strip())) if std_err and std_err.strip(): - s = to_str(std_err.strip()) - LOG.warn("Output on STDERR: {}".format(s)) + LOG.warn(_("Output on {}").format('STDERR') + ' ' + to_str(std_err.strip())) if ret_val: return False @@ -724,12 +723,12 @@ class PpDeployZonesApp(PpPDNSApplication): def apply_config(self): if not self.reload_necessary and not self.restart_necessary: - LOG.info("Reload or restart of named is not necessary.") + LOG.info(_("Reload or restart of named is not necessary.")) return running = self.named_running() if not running: - LOG.warn("Named is not running, please start it manually.") + LOG.warn(_("Named is not running, please start it manually.")) return if self.restart_necessary: @@ -740,11 +739,11 @@ class PpDeployZonesApp(PpPDNSApplication): # ------------------------------------------------------------------------- def named_running(self): - LOG.debug("Checking, whether named is running ...") + LOG.debug(_("Checking, whether named is running ...")) cmd = shlex.split(self.cmd_status) cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd)) - LOG.debug("Executing: {}".format(cmd_str)) + LOG.debug(_("Executing: {}").format(cmd_str)) std_out = None std_err = None @@ -758,13 +757,11 @@ class PpDeployZonesApp(PpPDNSApplication): std_out, std_err = proc.communicate() ret_val = proc.wait() - LOG.debug("Return value: {!r}".format(ret_val)) + LOG.debug(_("Return value: {!r}").format(ret_val)) if std_out and std_out.strip(): - s = to_str(std_out.strip()) - LOG.debug("Output on STDOUT:\n{}".format(s)) + LOG.debug(_("Output on {}").format('STDOUT') + '\n' + to_str(std_out.strip())) if std_err and std_err.strip(): - s = to_str(std_err.strip()) - LOG.warn("Output on STDERR: {}".format(s)) + LOG.warn(_("Output on {}").format('STDERR') + ' ' + to_str(std_err.strip())) if ret_val: return False @@ -774,11 +771,11 @@ class PpDeployZonesApp(PpPDNSApplication): # ------------------------------------------------------------------------- def start_named(self): - LOG.info("Starting named ...") + LOG.info(_("Starting {} ...").format('named')) cmd = shlex.split(self.cmd_start) cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd)) - LOG.debug("Executing: {}".format(cmd_str)) + LOG.debug(_("Executing: {}").format(cmd_str)) if self.simulate: return @@ -795,13 +792,11 @@ class PpDeployZonesApp(PpPDNSApplication): std_out, std_err = proc.communicate() ret_val = proc.wait() - LOG.debug("Return value: {!r}".format(ret_val)) + LOG.debug(_("Return value: {!r}").format(ret_val)) if std_out and std_out.strip(): - s = to_str(std_out.strip()) - LOG.debug("Output on STDOUT:\n{}".format(s)) + LOG.debug(_("Output on {}").format('STDOUT') + '\n' + to_str(std_out.strip())) if std_err and std_err.strip(): - s = to_str(std_err.strip()) - LOG.error("Output on STDERR: {}".format(s)) + LOG.error(_("Output on {}").format('STDERR') + ' ' + to_str(std_err.strip())) if ret_val: return False @@ -811,11 +806,11 @@ class PpDeployZonesApp(PpPDNSApplication): # ------------------------------------------------------------------------- def restart_named(self): - LOG.info("Restarting named ...") + LOG.info(_("Restarting {} ...").format('named')) cmd = shlex.split(self.cmd_restart) cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd)) - LOG.debug("Executing: {}".format(cmd_str)) + LOG.debug(_("Executing: {}").format(cmd_str)) if self.simulate: return @@ -832,13 +827,11 @@ class PpDeployZonesApp(PpPDNSApplication): std_out, std_err = proc.communicate() ret_val = proc.wait() - LOG.debug("Return value: {!r}".format(ret_val)) + LOG.debug(_("Return value: {!r}").format(ret_val)) if std_out and std_out.strip(): - s = to_str(std_out.strip()) - LOG.debug("Output on STDOUT:\n{}".format(s)) + LOG.debug(_("Output on {}").format('STDOUT') + '\n' + to_str(std_out.strip())) if std_err and std_err.strip(): - s = to_str(std_err.strip()) - LOG.error("Output on STDERR: {}".format(s)) + LOG.error(_("Output on {}").format('STDERR') + ' ' + to_str(std_err.strip())) if ret_val: return False @@ -848,11 +841,11 @@ class PpDeployZonesApp(PpPDNSApplication): # ------------------------------------------------------------------------- def reload_named(self): - LOG.info("Reloading named ...") + LOG.info(_("Reloading {} ...").format('named')) cmd = shlex.split(self.cmd_reload) cmd_str = ' '.join(map(lambda x: pipes.quote(x), cmd)) - LOG.debug("Executing: {}".format(cmd_str)) + LOG.debug(_("Executing: {}").format(cmd_str)) if self.simulate: return @@ -869,13 +862,11 @@ class PpDeployZonesApp(PpPDNSApplication): std_out, std_err = proc.communicate() ret_val = proc.wait() - LOG.debug("Return value: {!r}".format(ret_val)) + LOG.debug(_("Return value: {!r}").format(ret_val)) if std_out and std_out.strip(): - s = to_str(std_out.strip()) - LOG.debug("Output on STDOUT:\n{}".format(s)) + LOG.debug(_("Output on {}").format('STDOUT') + '\n' + to_str(std_out.strip())) if std_err and std_err.strip(): - s = to_str(std_err.strip()) - LOG.error("Output on STDERR: {}".format(s)) + LOG.error(_("Output on {}").format('STDERR') + ' ' + to_str(std_err.strip())) if ret_val: return False