]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Adding lib/webhooks/show_modules.py and show-modules
authorFrank Brehm <frank.brehm@pixelpark.com>
Fri, 24 Aug 2018 13:21:18 +0000 (15:21 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Fri, 24 Aug 2018 13:21:18 +0000 (15:21 +0200)
lib/webhooks/__init__.py
lib/webhooks/get_forge_modules.py
lib/webhooks/show_modules.py [new file with mode: 0644]
show-modules [new file with mode: 0755]

index 7f386bfa85f411f852eb12582b4f86debdd56535..7c3b277f320fbad540d0ae1bc5ea8f6d2a80752b 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/env python3
 # -*- coding: utf-8 -*-
 
-__version__ = '0.9.10'
+__version__ = '0.10.0'
 
 # vim: ts=4 et list
index 4dd22eb3d4be965c3fc5614f0659b093ac0be916..ccbf230ba9f8c9f7459b42b567e391ed95367a1b 100644 (file)
@@ -94,7 +94,7 @@ class GetForgeModulesApp(BaseHookApp):
     def post_init(self):
 
         self.read_stdin = False
-        self.cache_file = os.path.join(self.data_dir, self.appname + '.yaml')
+        self.cache_file = os.path.join(self.data_dir, 'modules-info.yaml')
 
         self.initialized = True
 
diff --git a/lib/webhooks/show_modules.py b/lib/webhooks/show_modules.py
new file mode 100644 (file)
index 0000000..da70f14
--- /dev/null
@@ -0,0 +1,90 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@copyright: © 2017 by Frank Brehm, Berlin
+@summary: The module for the show-module CGI application to show
+          information about all Puppet modules from cache.
+"""
+from __future__ import absolute_import
+
+# Standard modules
+import os
+import logging
+import textwrap
+import copy
+
+# Third party modules
+
+# Own modules
+from . import __version__
+
+from .common import pp, to_str
+
+from .base_app import BaseHookApp
+
+LOG = logging.getLogger(__name__)
+
+DEFAULT_PARENT_DIR = '/etc/puppetlabs/code/fileserver'
+
+
+# =============================================================================
+class ShowModulesApp(BaseHookApp):
+    """
+    Class for the application objects.
+    """
+
+    # -------------------------------------------------------------------------
+    def __init__(self, appname=None, verbose=0, version=__version__):
+        """Constructor."""
+
+        self.description = textwrap.dedent('''\
+            returns a list with all used Puppet modules
+            ''').strip()
+
+        self.cache_file = None
+
+        super(ShowModulesApp, self).__init__(
+            appname=appname, verbose=verbose, version=version)
+
+#    # -------------------------------------------------------------------------
+#    def as_dict(self, short=True):
+#        """
+#        Transforms the elements of the object into a dict
+#
+#        @return: structure as dict
+#        @rtype:  dict
+#        """
+#
+#        res = super(ShowModulesApp, self).as_dict()
+#
+#        return res
+
+    # -------------------------------------------------------------------------
+    def evaluate_config(self, config, yaml_file):
+
+        super(ShowModulesApp, self).evaluate_config(config, yaml_file)
+
+    # -------------------------------------------------------------------------
+    def post_init(self):
+
+        self.read_stdin = False
+        self.cache_file = os.path.join(self.data_dir, 'modules-info.yaml')
+
+        self.initialized = True
+
+    # -------------------------------------------------------------------------
+    def run(self):
+        """Main routine."""
+
+        self.print_out("Hallo!")
+
+# =============================================================================
+
+if __name__ == "__main__":
+
+    pass
+
+# =============================================================================
+# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 list
diff --git a/show-modules b/show-modules
new file mode 100755 (executable)
index 0000000..8b7eb7f
--- /dev/null
@@ -0,0 +1,29 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+# Standard modules
+import os
+import sys
+import logging
+
+# own modules:
+basedir = os.path.abspath(os.path.dirname(__file__))
+libdir = os.path.join(basedir, 'lib')
+
+sys.path.insert(0, libdir)
+
+from webhooks.show_modules import ShowModulesApp
+
+MY_APPNAME = os.path.basename(sys.argv[0])
+LOG = logging.getLogger(MY_APPNAME)
+
+app = ShowModulesApp(appname=MY_APPNAME)
+
+if app.verbose > 2:
+    LOG.debug("{c} object:\n{o}".format(c=app.__class__.__name__, o=app))
+
+app()
+
+sys.exit(0)
+
+# vim: ts=4 et