From: Frank Brehm Date: Mon, 20 Feb 2017 12:18:14 +0000 (+0100) Subject: Bugfixing because of character encoding X-Git-Tag: 0.8.4~14 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=d6973fbb766db6685d9657f9f8a2408543e0903a;p=pixelpark%2Fpuppetmaster-webhooks.git Bugfixing because of character encoding --- diff --git a/lib/webhooks/__init__.py b/lib/webhooks/__init__.py index 24b9f3e..77c24cf 100644 --- a/lib/webhooks/__init__.py +++ b/lib/webhooks/__init__.py @@ -1,6 +1,6 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '0.5.4' +__version__ = '0.5.5' # vim: ts=4 et list diff --git a/lib/webhooks/base_app.py b/lib/webhooks/base_app.py index 3d5ab95..f19e087 100644 --- a/lib/webhooks/base_app.py +++ b/lib/webhooks/base_app.py @@ -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: