]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Applied flake8 rules
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 15 Feb 2017 15:51:10 +0000 (16:51 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 15 Feb 2017 15:51:10 +0000 (16:51 +0100)
deploy.py
lib/webhooks/__init__.py
lib/webhooks/base_app.py
lib/webhooks/common.py
lib/webhooks/deploy.py
lib/webhooks/r10k.py
r10k_hook-new.py

index 32317a3523270b6062d236bef84c9f2d6f0f2a3d..4e209aa5a36a608177bfe399cfd59d105288fff5 100755 (executable)
--- a/deploy.py
+++ b/deploy.py
@@ -12,10 +12,7 @@ libdir = os.path.join(basedir, 'lib')
 
 sys.path.insert(0, libdir)
 
-
-import webhooks
-
-from webhooks.deploy import WebhookDeployApp
+from webhooks.deploy import WebhookDeployApp        # noqa
 
 MY_APPNAME = 'deploy'
 LOG = logging.getLogger(MY_APPNAME)
index 7e334209028f8f6192641129a3533a12b606cb5c..f111991fbeb8b3afe3dee5934ede2102dce53cc9 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/env python3
 # -*- coding: utf-8 -*-
 
-__version__ = '0.5.1'
+__version__ = '0.5.2'
 
 # vim: ts=4 et list
index a8f8a7e41f965fe24ffd0742fe349fb8497827a5..3d5ab9595cd14fabd5c40862e10c99d069079592 100644 (file)
@@ -12,7 +12,6 @@ import sys
 import os
 import logging
 import re
-import textwrap
 import datetime
 import json
 import smtplib
@@ -26,7 +25,7 @@ import yaml
 # Own modules
 import webhooks
 
-from webhooks.common import pp, to_bytes, to_str, to_bool
+from webhooks.common import pp, to_bytes, to_bool
 
 __version__ = webhooks.__version__
 LOG = logging.getLogger(__name__)
@@ -204,7 +203,6 @@ class BaseHookApp(object):
     # -------------------------------------------------------------------------
     def do_arg_parser(self):
 
-
         arg_parser = argparse.ArgumentParser(
             description=self.description,
             add_help=False,
@@ -470,7 +468,6 @@ class BaseHookApp(object):
             sys.stderr.flush()
             os.dup2(se.fileno(), sys.stderr.fileno())
 
-            #sys.stderr.write("Trying to open logfile {!r} ...\n".format(self.logfile))
             # we are in a CGI environment
             if os.path.isdir(self.log_directory) and os.access(self.log_directory, os.W_OK):
                 lh_file = logging.FileHandler(
@@ -556,6 +553,8 @@ class BaseHookApp(object):
         if self.special_chars_re.search(self.name):
             msg = "Project {!r}: Received special characters in module name".format(
                 self.full_name)
+            LOG.error(msg)
+            self.error_data.append(msg)
             return False
 
         committers = []
@@ -674,4 +673,3 @@ if __name__ == "__main__":
 
 # =============================================================================
 # vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list
-
index 75b2b04cfb2e6faa47a853f77734966c9495440f..fef20025c45d62bda9d255ed4fb11c715ff9fd71 100644 (file)
@@ -142,7 +142,6 @@ def to_str(obj, encoding='utf-8'):
     return to_unicode(obj, encoding)
 
 
-
 # =============================================================================
 def to_bool(value):
     """
index 1f9527c0dcf3973ede6e66e0ae6679866e7c2bff..7df47492bb2ef7ed915917d21748c751986cee82 100644 (file)
@@ -8,27 +8,19 @@
 """
 
 # Standard modules
-import sys
 import os
 import logging
-import re
 import textwrap
-import datetime
-import json
-import traceback
 import copy
 import pipes
 import subprocess
-import smtplib
-from email.message import EmailMessage
 
 # Third party modules
-import yaml
 
 # Own modules
 import webhooks
 
-from webhooks.common import pp, to_bytes, to_str, to_bool
+from webhooks.common import pp, to_str
 
 from webhooks.base_app import BaseHookApp
 
@@ -77,7 +69,6 @@ class WebhookDeployApp(BaseHookApp):
 
         return res
 
-
     # -------------------------------------------------------------------------
     def evaluate_config(self, config, yaml_file):
 
@@ -132,7 +123,7 @@ class WebhookDeployApp(BaseHookApp):
                     'modified': ['lib/webhooks/deploy.py'],
                     'removed': [],
                     'timestamp': '2017-01-25T11:20:47+01:00',
-                    'url': 'https://git.pixelpark.com/ppadmin/puppetmaster-webhooks/commit/257b9...'
+                    'url': 'https://git.pixelpark.com/ppadmin/puppetmaster-webhooks/commit/257b...'
                 }
             ],
             'event_name': 'push',
@@ -210,9 +201,7 @@ class WebhookDeployApp(BaseHookApp):
 
         LOG.info("Deploying Hiera working directory ...")
 
-        ns = 'puppet'
         pname = 'hiera'
-        full_name = ns + '/' + pname
         parent_dir = '/www/data/puppet-hiera'
         if 'parent_dir' in cfg and cfg['parent_dir']:
             parent_dir = cfg['parent_dir']
@@ -238,59 +227,6 @@ class WebhookDeployApp(BaseHookApp):
 
         return self.ensure_workingdir(parent_dir, workdir)
 
-    # -------------------------------------------------------------------------
-    def deploy_puppet_modules(self):
-
-        LOG.info("Deploying puppet modules working directory ...")
-
-        ns = 'puppet'
-        pname = cfg['name']
-        full_name = ns + '/' + pname
-        parent_dir = self.default_parent_dir
-        if 'parent_dir' in cfg and cfg['parent_dir']:
-            parent_dir = cfg['parent_dir']
-
-        if not os.access(parent_dir, os.F_OK):
-            msg = "Parent directory {d!r} of project {p!r} does not exists.".format(
-                d=parent_dir, p=full_name)
-            LOG.error(msg)
-            self.error_data.append(msg)
-            return True
-
-        if not os.path.isdir(parent_dir):
-            msg = ("Path for parent directory {d!r} for project {p!r} "
-                "is not a directory.").format(d=parent_dir, p=full_name)
-            LOG.error(msg)
-            self.error_data.append(msg)
-            return True
-
-        env_branch = 'undefined'
-        if self.dev_re.match(self.ref):
-            env_branch = 'development'
-        elif self.ref == 'master':
-            env_branch = 'test'
-        full_path_branch = os.path.join(parent_dir, env_branch)
-        if not os.access(full_path_branch, os.F_OK):
-            msg = "Branch directory {d!r} of project {p!r} does not exists.".format(
-                d=full_path_branch, p=full_name)
-            LOG.error(msg)
-            self.error_data.append(msg)
-            return True
-
-        modules_dir = os.path.join(full_path_branch, 'modules')
-        if not os.access(modules_dir, os.F_OK):
-            msg = "Modules directory {d!r} of project {p!r} does not exists.".format(
-                d=modules_dir, p=full_name)
-            LOG.error(msg)
-            self.error_data.append(msg)
-            return True
-
-        branc2clone = None
-        if env_branch =='test':
-            branc2clone = 'master'
-
-        return self.ensure_workingdir(parent_dir=modules_dir, workdir=pname, branch=branc2clone)
-
     # -------------------------------------------------------------------------
     def deploy(self, cfg):
 
index 98ed8640e3b952d28d563146792f58009a2a807b..489382caa23a21874a9320e0055da66c46912bcc 100644 (file)
 import sys
 import os
 import logging
-import re
 import textwrap
-import datetime
 import locale
 import pipes
 import subprocess
 import urllib.parse
 
 # Third party modules
-import yaml
 
 # Own modules
 import webhooks
 
-from webhooks.common import pp, to_bytes, to_str, to_bool
+from webhooks.common import pp, to_str, to_bool
 
 from webhooks.base_app import BaseHookApp
 
@@ -143,8 +140,8 @@ class R10kHookApp(BaseHookApp):
                 try:
                     self.puppetmaster_api_port = int(ppm_cfg['api_port'])
                 except Exception as e:
-                    msg = "Invalid port {p!r} for puppetmaster API in {f!r} found.".format(
-                        p=ppm_cfg['api_port'], f=yaml_file)
+                    msg = "Invalid port {p!r} for puppetmaster API in {f!r} found: {e}".format(
+                        p=ppm_cfg['api_port'], f=yaml_file, e=e)
                     self.error_data.append(msg)
             if 'api_path' in ppm_cfg and ppm_cfg['api_path']:
                 self.puppetmaster_api_path = ppm_cfg['api_path']
@@ -185,7 +182,7 @@ class R10kHookApp(BaseHookApp):
             self.puppetmaster_ssl_dir, 'certs', 'ca.pem')
 
         path = (
-            self.puppetmaster_api_path + '/environment-cache?environment=' + 
+            self.puppetmaster_api_path + '/environment-cache?environment=' +
             urllib.parse.quote(self.ref))
         url = 'https://{h}:{po}{pa}'.format(
             h=self.puppetmaster_host, po=self.puppetmaster_api_port, pa=path)
index b7a318987a0df17eceaa2952787f4d0b1f568658..a8baaaffb562601c48863f62cc2bf5309e474a59 100755 (executable)
@@ -12,10 +12,7 @@ libdir = os.path.join(basedir, 'lib')
 
 sys.path.insert(0, libdir)
 
-
-import webhooks
-
-from webhooks.r10k import R10kHookApp
+from webhooks.r10k import R10kHookApp           # noqa
 
 MY_APPNAME = 'r10k-hook'
 LOG = logging.getLogger(MY_APPNAME)