]> Frank Brehm's Git Trees - pixelpark/puppetmaster-webhooks.git/commitdiff
Bugfixing because of character encoding
authorFrank Brehm <frank.brehm@pixelpark.com>
Mon, 20 Feb 2017 12:18:14 +0000 (13:18 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Mon, 20 Feb 2017 12:18:14 +0000 (13:18 +0100)
lib/webhooks/__init__.py
lib/webhooks/base_app.py

index 24b9f3e47aaf5d94cfb6bee5be20aba0f1d0652a..77c24cfb6902f11696a61f8bfc6ef7739a4b8e2e 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/env python3
 # -*- coding: utf-8 -*-
 
-__version__ = '0.5.4'
+__version__ = '0.5.5'
 
 # vim: ts=4 et list
index 3d5ab9595cd14fabd5c40862e10c99d069079592..f19e08745c033036fb674f99f6b766f0435bef66 100644 (file)
@@ -17,6 +17,8 @@ import json
 import smtplib
 import argparse
 import traceback
+import io
+
 from email.message import EmailMessage
 
 # Third party modules
@@ -514,8 +516,15 @@ class BaseHookApp(object):
 
         if self.verbose > 1:
             LOG.debug("Base directory: {!r}".format(self.base_dir))
+            LOG.debug("STDIN object: {}".format(sys.stdin.__class__.__name__))
+            LOG.debug("Encoding of STDIN: {!r}".format(sys.stdin.encoding))
+
+        LOG.debug("Setting encoding of STDIN to 'UTF-8'.")
+        input_stream = io.TextIOWrapper(sys.stdin.buffer, encoding='UTF-8')
+        if self.verbose > 2:
+            LOG.debug("Encoding of STDIN now: {!r}".format(input_stream.encoding))
 
-        self.data = sys.stdin.read()
+        self.data = input_stream.read()
         try:
             self.json_data = json.loads(self.data)
             if self.verbose > 1: