From: Frank Brehm Date: Fri, 7 Dec 2018 13:50:58 +0000 (+0100) Subject: Start refactoring lib/webhooks/base_app.py X-Git-Tag: 1.6.4^2~103 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=9e4922719e0b7fffd615e202aa89fd4d40cd7a77;p=pixelpark%2Fpuppetmaster-webhooks.git Start refactoring lib/webhooks/base_app.py --- 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')