From: Frank Brehm Date: Fri, 29 May 2020 10:52:25 +0000 (+0200) Subject: put checking for a remote directory into a seperate method X-Git-Tag: 2.1.2^2~9^2~31^2~79 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=61c5162a247dfd051811ac0e847f8710d87ac58a;p=pixelpark%2Fcreate-vmware-tpl.git put checking for a remote directory into a seperate method --- 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):