From 8cc687f05d1cb52c618bf16df1a7fb6d0adc7edd Mon Sep 17 00:00:00 2001 From: dortega Date: Tue, 29 Aug 2017 14:50:19 +0200 Subject: [PATCH 1/4] #18 Allowing to be installed under Python 3.5.x --- CHANGELOG.md | 5 +++++ prom2teams/server.py | 11 ++++++----- prom2teams/teams/client.py | 11 +++++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 37422b2..27adc46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,11 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch ## [Unreleased](https://github.com/idealista/prom2teams/tree/develop) +## [1.1.2](https://github.com/idealista/prom2teams/tree/1.1.2) +[Full Changelog](https://github.com/idealista/prom2teams/compare/1.1.1...1.1.2) +### Fixed +- *[#15](https://github.com/idealista/prom2teams/issues/18) Allow to be installed under Python 3.5.x * @dortegau + ## [1.1.1](https://github.com/idealista/prom2teams/tree/1.1.1) [Full Changelog](https://github.com/idealista/prom2teams/compare/1.1.0...1.1.1) ### Fixed diff --git a/prom2teams/server.py b/prom2teams/server.py index 3a3ae97..442532a 100644 --- a/prom2teams/server.py +++ b/prom2teams/server.py @@ -30,17 +30,18 @@ def _set_headers(self, status_code): def do_POST(self): try: - content_length = self.headers['Content-Length'] - post_data = self.rfile.read(int(content_length)) + content_length = int(self.headers['Content-Length']) + post_data = self.rfile.read(content_length).decode('utf-8') - logger.debug(f'Data received: {post_data}') + logger.debug('Data received: %s', post_data) message = compose(self.template_path, parse(post_data)) - logger.debug(f'The message that will be sent is: {message}') + logger.debug('The message that will be sent is: %s', + str(message)) post(self.teams_webhook_url, message) self._set_headers(200) except Exception as e: - logger.error('Error processing request: %s', str(e)) + logger.exception('Error processing request: %s', str(e)) self.send_error(500, 'Error processing request') def log_message(self, format, *args): diff --git a/prom2teams/teams/client.py b/prom2teams/teams/client.py index 5ec3aa4..04a24af 100644 --- a/prom2teams/teams/client.py +++ b/prom2teams/teams/client.py @@ -13,7 +13,10 @@ def post(teams_webhook_url, message): data=message) if not response.ok: - exception_msg = f'Error performing request to: {teams_webhook_url}.' \ - f' Returned status code: {response.status_code}.' \ - f' Returned data: {response.text}' - raise MicrosoftTeamsRequestException(exception_msg) + exception_msg = 'Error performing request to: {}.' \ + ' Returned status code: {}.' \ + ' Returned data: {}' + + raise MicrosoftTeamsRequestException(exception_msg.format(teams_webhook_url, + str(response.status_code), + str(response.text))) From 628fc0a56e997461cdf2bb2f999c4a35c82d41b6 Mon Sep 17 00:00:00 2001 From: dortega Date: Tue, 29 Aug 2017 14:54:38 +0200 Subject: [PATCH 2/4] #18 Updating README and setup.py files --- README.md | 4 ++-- setup.py | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2072825..7f3f3d9 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ ### Prerequisites -The application has been tested with _Prometheus 1.7.1_, _Python 3.6.2_ and _pip 9.0.1_. +The application has been tested with _Prometheus 1.7.1_, _Python 3.5.0_ and _pip 9.0.1_. Newer versions of _Prometheus/Python/pip_ should work but could also present issues. @@ -38,7 +38,7 @@ prom2teams is present on [PyPI](https://pypi.python.org/pypi/prom2teams), so cou $ pip3 install prom2teams ``` -**Note:** Only works since v1.1.1 +**Note:** Only works since v1.1.1 ## Usage diff --git a/setup.py b/setup.py index 9714e97..361bfb8 100644 --- a/setup.py +++ b/setup.py @@ -51,6 +51,7 @@ def read_requirements_file(): 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'Programming Language :: Python', + 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6' ], zip_safe=False) From 07dac78ad2aaf1dca6f33b66fb5d64dc35e849e8 Mon Sep 17 00:00:00 2001 From: dortega Date: Tue, 29 Aug 2017 14:59:17 +0200 Subject: [PATCH 3/4] updating current version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 361bfb8..ed3bd69 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ def read_requirements_file(): setup(name='prom2teams', - version='1.1.1', + version='1.1.2', description='Project that redirects Prometheus Alert Manager ' 'notifications to Microsoft Teams', long_description=readme, From 59358b3ae163bc7a86bd19c7d8ffc8a0e1feaaaa Mon Sep 17 00:00:00 2001 From: dortega Date: Tue, 29 Aug 2017 15:01:30 +0200 Subject: [PATCH 4/4] adding python 3.5 to travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index bf9db52..f21b7e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: python python: + - "3.5" - "3.6" install: "pip install -r requirements.txt" script: python -m unittest discover tests