Skip to content

Commit

Permalink
Merge pull request #20 from idealista/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dortegau authored Aug 29, 2017
2 parents dcd522b + 59358b3 commit 38a1630
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 12 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: python
python:
- "3.5"
- "3.6"
install: "pip install -r requirements.txt"
script: python -m unittest discover tests
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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

Expand Down
11 changes: 6 additions & 5 deletions prom2teams/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 7 additions & 4 deletions prom2teams/teams/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)

0 comments on commit 38a1630

Please sign in to comment.