From 61c5162a247dfd051811ac0e847f8710d87ac58a Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 29 May 2020 12:52:25 +0200 Subject: [PATCH] put checking for a remote directory into a seperate method --- lib/cr_vmware_tpl/cobbler.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/cr_vmware_tpl/cobbler.py b/lib/cr_vmware_tpl/cobbler.py index 1130864..4d960b5 100644 --- a/lib/cr_vmware_tpl/cobbler.py +++ b/lib/cr_vmware_tpl/cobbler.py @@ -35,7 +35,7 @@ from .config import CrTplConfiguration from .xlate import XLATOR -__version__ = '0.3.8' +__version__ = '0.3.9' LOG = logging.getLogger(__name__) @@ -242,7 +242,13 @@ class Cobbler(BaseHandler): cobbler_version = re.sub(r'^\s*cobbler\s+', '', first_line, flags=re.IGNORECASE).strip() LOG.info(_("Version of {} is:").format("Cobbler") + " {!r}".format(cobbler_version)) - rdir = self.config.cobbler_rootdir + self.check_remote_directory(self.config.cobbler_rootdir, _('Cobbler root directory')) + + return cobbler_version + + # ------------------------------------------------------------------------- + def check_remote_directory(self, rdir, desc=None): + if self.verbose > 1: msg = _("Checking existence of remote directory {!r} ...").format(str(rdir)) LOG.debug(msg) @@ -256,12 +262,15 @@ class Cobbler(BaseHandler): proc = self.exec_ssh(cmd) if proc.returncode != 0: + dsc = _('Remote directory') + if desc: + dsc = desc msg = _( - "Cobbler root directory {rdir!r} on host {host!r} does not " - "exists or is not a directory.").format(rdir=str(rdir), host=self.host) + "{dsc} {rdir!r} on host {host!r} does not exists or is not a directory.").format( + dsc=dsc, rdir=str(rdir), host=self.host) raise ExpectedCobblerError(msg) - return cobbler_version + # ------------------------------------------------------------------------- def get_distro_list(self): -- 2.39.5