import re
import textwrap
import datetime
+import json
# Own modules
import webhooks
+from webhooks.common import pp
__version__ = webhooks.__version__
log = logging.getLogger(__name__)
@type: int
"""
+ self.data = None
+ self.json_data = None
+
self._log_directory = os.sep + os.path.join('var', 'log', 'webhooks')
self.init_logging()
if 'REQUEST_METHOD' in os.environ:
- sys.stderr.write("Trying to open logfile {!r} ...\n".format(self.logfile))
+ #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(
log.info("Starting ...")
log.debug("Base directory: {!r}".format(self.base_dir))
+ self.data = sys.stdin.read()
+ try:
+ self.json_data = json.loads(self.data)
+ except Exception as e:
+ LOG.error("Got a {n} reading input data: {e}".format(n=e.__class__.__name__, e))
+ LOG.error("Input data:\n{}".format(self.data)
+ sys.exit(0)
+ LOG.debug("Got data:\n{}".format(pp(self.json_data)))
+ sys.exit(0)
# =============================================================================