Skip to content

Commit

Permalink
Merge pull request #17 from idealista/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
dortegau authored Aug 28, 2017
2 parents 32e78ae + 7637df1 commit dcd522b
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 14 deletions.
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.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
- *[#15](https://github.com/idealista/prom2teams/issues/15) Fixing setuptools config and packaging (broken in versions 1.1.0 and 1.0.0) * @dortegau

## [1.1.0](https://github.com/idealista/prom2teams/tree/1.1.0)
[Full Changelog](https://github.com/idealista/prom2teams/compare/1.0.0...1.1.0)
### Added
Expand Down
4 changes: 4 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
include README.md
include LICENSE
include requirements.txt
include config.ini
include logging_console_config.ini
include logging_file_config.ini
include prom2teams/teams/template.j2
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ prom2teams is present on [PyPI](https://pypi.python.org/pypi/prom2teams), so cou
$ pip3 install prom2teams
```

**Note:** Only works since v1.1.1

## Usage

```bash
Expand Down
7 changes: 5 additions & 2 deletions bin/prom2teams
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import sys
import os
import argparse

sys.path.append(os.path.abspath('./app'))
from server import run
try:
from prom2teams.server import run
except ImportError:
sys.path.append(os.path.abspath('./'))
from prom2teams.server import run

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Receives alert notifications '
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 10 additions & 7 deletions app/server.py → prom2teams/server.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import logging
import configparser
import os

from http.server import BaseHTTPRequestHandler, HTTPServer
from logging.config import fileConfig

from teams.client import post
from teams.json_composer import compose
from message.parser import parse
from prom2teams.teams.client import post
from prom2teams.teams.json_composer import compose
from prom2teams.message.parser import parse

from exceptions import MissingConnectorConfigKeyException
from prom2teams.exceptions import MissingConnectorConfigKeyException


logger = logging.getLogger()
dir = os.path.dirname(__file__)


def generate_request_handler(teams_webhook_url, template_path):
Expand Down Expand Up @@ -50,7 +52,8 @@ def log_message(self, format, *args):


def run(provided_config_file, template_path, log_file_path, log_level):
config = get_config('config.ini', provided_config_file)
config = get_config(os.path.join(dir, 'config.ini'),
provided_config_file)

load_logging_config(log_file_path, log_level)

Expand All @@ -72,11 +75,11 @@ def run(provided_config_file, template_path, log_file_path, log_level):


def load_logging_config(log_file_path, log_level):
config_file = 'logging_console_config.ini'
config_file = os.path.join(dir, 'logging_console_config.ini')
defaults = {'log_level': log_level}

if(log_file_path):
config_file = 'logging_file_config.ini'
config_file = os.path.join(dir, 'logging_file_config.ini')
defaults = {
'log_level': log_level,
'log_file_path': log_file_path
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 4 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.0',
version='1.1.1',
description='Project that redirects Prometheus Alert Manager '
'notifications to Microsoft Teams',
long_description=readme,
Expand All @@ -34,6 +34,9 @@ def read_requirements_file():
'pypandoc'
],
scripts=['bin/prom2teams'],
package_data = {
'': ['*.ini', '*.j2',],
},
url='http://github.com/idealista/prom2teams',
author='Idealista, S.A.U',
author_email='[email protected]',
Expand Down
5 changes: 2 additions & 3 deletions tests/context.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import sys

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../app')))
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '../prom2teams')))

import server
import exceptions
from prom2teams import server, exceptions
2 changes: 1 addition & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class TestServer(unittest.TestCase):

TEST_CONFIG_FILES_PATH = 'tests/data/'
DEFAULT_CONFIG_RELATIVE_PATH = './config.ini'
DEFAULT_CONFIG_RELATIVE_PATH = './prom2teams/config.ini'

def test_get_config_with_invalid_path(self):
invalid_relative_path = self.TEST_CONFIG_FILES_PATH + 'invalid_path'
Expand Down

0 comments on commit dcd522b

Please sign in to comment.