From 9e4922719e0b7fffd615e202aa89fd4d40cd7a77 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Fri, 7 Dec 2018 14:50:58 +0100 Subject: [PATCH] Start refactoring lib/webhooks/base_app.py --- lib/webhooks/__init__.py | 2 +- lib/webhooks/base_app.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/webhooks/__init__.py b/lib/webhooks/__init__.py index aff0281..e9542dc 100644 --- a/lib/webhooks/__init__.py +++ b/lib/webhooks/__init__.py @@ -1,6 +1,6 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '1.2.4' +__version__ = '1.3.0' # vim: ts=4 et list diff --git a/lib/webhooks/base_app.py b/lib/webhooks/base_app.py index ab1ba3e..dd6eeb2 100644 --- a/lib/webhooks/base_app.py +++ b/lib/webhooks/base_app.py @@ -32,11 +32,14 @@ from email.message import EmailMessage import six import yaml import pytz +import pathlib # Own modules from fb_tools.common import pp, to_bytes, to_bool -from fb_tools.obj import FbBaseObjectError, FbBaseObject +from fb_tools.obj import FbBaseObject from fb_tools.handler import BaseHandler +from fb_tools.errors import FbAppError +from fb_tools.app import BaseApplication from . import __version__ as __pkg_version__ @@ -55,7 +58,7 @@ DEFAULT_TO_SENDER = 'Puppet <{}>'.format(DEFAULT_TO_EMAIL) # ============================================================================= -class BaseHookError(FbBaseObjectError): +class BaseHookError(FbAppError): """ Base error class useable by all descendand objects. """ @@ -69,12 +72,12 @@ class UncriticalHookError(BaseHookError): """ # ============================================================================= -class BaseHookApp(FbBaseObject): +class BaseHookApp(BaseApplication): """ Base class for the application objects. """ - cgi_bin_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) + cgi_bin_dir = pathlib.Path(__file__).parent.parent.resolve() puppetlabs_cfg_dir = os.sep + os.path.join('etc', 'puppetlabs') puppet_envs_dir = os.path.join(puppetlabs_cfg_dir, 'code', 'environments') -- 2.39.5