From 83e88a2fe04cd450bc5cc47090eec1026238e9e4 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 20 Aug 2018 12:33:06 +0200 Subject: [PATCH] Bugfixing, adding path to puppet binary in base application class --- lib/webhooks/__init__.py | 2 +- lib/webhooks/base_app.py | 15 +++++++++++++++ lib/webhooks/deploy.py | 24 ++++++++++++------------ lib/webhooks/handler.py | 5 +++++ lib/webhooks/r10k.py | 15 +++++++++++---- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/lib/webhooks/__init__.py b/lib/webhooks/__init__.py index f7ee2b6..b65ba7f 100644 --- a/lib/webhooks/__init__.py +++ b/lib/webhooks/__init__.py @@ -1,6 +1,6 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '0.8.1' +__version__ = '0.8.2' # vim: ts=4 et list diff --git a/lib/webhooks/base_app.py b/lib/webhooks/base_app.py index 6c2925b..2a3f1b6 100644 --- a/lib/webhooks/base_app.py +++ b/lib/webhooks/base_app.py @@ -96,6 +96,7 @@ class BaseHookApp(BaseObject): self.cmdline_args = None + self.puppet_bin = None self.curl_bin = None self.error_data = [] @@ -121,6 +122,7 @@ class BaseHookApp(BaseObject): else: LOG.debug("We are NOT in CGI.") + self.search_puppet_bin() self.search_curl_bin() return @@ -243,6 +245,19 @@ class BaseHookApp(BaseObject): sys.stderr.write("\nSimulation mode - nothing is really done.\n\n") self.simulate = True + # ------------------------------------------------------------------------- + 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 + if not cmd: + sys.exit(9) + self.puppet_bin = cmd + return + # ------------------------------------------------------------------------- def search_curl_bin(self): diff --git a/lib/webhooks/deploy.py b/lib/webhooks/deploy.py index e46a5d9..d24bc1e 100644 --- a/lib/webhooks/deploy.py +++ b/lib/webhooks/deploy.py @@ -56,18 +56,18 @@ class WebhookDeployApp(BaseHookApp): super(WebhookDeployApp, self).__init__( appname=appname, verbose=verbose, version=version) - # ------------------------------------------------------------------------- - def as_dict(self): - """ - Transforms the elements of the object into a dict - - @return: structure as dict - @rtype: dict - """ - - res = super(WebhookDeployApp, self).as_dict() - - return res +# # ------------------------------------------------------------------------- +# def as_dict(self, short=True): +# """ +# Transforms the elements of the object into a dict +# +# @return: structure as dict +# @rtype: dict +# """ +# +# res = super(WebhookDeployApp, self).as_dict() +# +# return res # ------------------------------------------------------------------------- def evaluate_config(self, config, yaml_file): diff --git a/lib/webhooks/handler.py b/lib/webhooks/handler.py index 8024a65..b9046f1 100644 --- a/lib/webhooks/handler.py +++ b/lib/webhooks/handler.py @@ -249,6 +249,11 @@ class BaseHandler(BaseObject): out += ", ".join(fields) + ")>" return out + # ------------------------------------------------------------------------- + def get_cmd(self, cmd): + + return self.get_command(cmd) + # ------------------------------------------------------------------------- def get_command(self, cmd, quiet=False): """ diff --git a/lib/webhooks/r10k.py b/lib/webhooks/r10k.py index 38b64f4..873c649 100644 --- a/lib/webhooks/r10k.py +++ b/lib/webhooks/r10k.py @@ -6,6 +6,7 @@ @copyright: © 2017 by Frank Brehm, Berlin @summary: The module for the r10k_hook application object. """ +from __future__ import absolute_import # Standard modules import sys @@ -25,9 +26,11 @@ import requests # Own modules import webhooks -from webhooks.common import pp, to_str, to_bool +from .common import pp, to_str, to_bool -from webhooks.base_app import BaseHookApp +from .base_app import BaseHookApp + +from .handler import BaseHandler __version__ = webhooks.__version__ LOG = logging.getLogger(__name__) @@ -66,7 +69,7 @@ class R10kHookApp(BaseHookApp): self.check_cert_files() # ------------------------------------------------------------------------- - def as_dict(self): + def as_dict(self, short=True): """ Transforms the elements of the object into a dict @@ -81,7 +84,11 @@ class R10kHookApp(BaseHookApp): # ------------------------------------------------------------------------- def search_r10k_bin(self): - cmd = self.get_cmd('r10k') + searcher = BaseHandler( + appname=self.appname, verbose=self.verbose, base_dir=self.base_dir) + + cmd = searcher.get_cmd('r10k') + del searcher if not cmd: sys.exit(9) self.r10k_bin = cmd -- 2.39.5