diff --git a/CHANGELOG.md b/CHANGELOG.md index 02c0775..37422b2 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.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 diff --git a/MANIFEST.in b/MANIFEST.in index bb910eb..1bdaeaf 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -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 diff --git a/README.md b/README.md index 97f6d25..2072825 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/prom2teams b/bin/prom2teams index 8d86284..7add482 100755 --- a/bin/prom2teams +++ b/bin/prom2teams @@ -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 ' diff --git a/app/__init__.py b/prom2teams/__init__.py similarity index 100% rename from app/__init__.py rename to prom2teams/__init__.py diff --git a/config.ini b/prom2teams/config.ini similarity index 100% rename from config.ini rename to prom2teams/config.ini diff --git a/app/exceptions.py b/prom2teams/exceptions.py similarity index 100% rename from app/exceptions.py rename to prom2teams/exceptions.py diff --git a/logging_console_config.ini b/prom2teams/logging_console_config.ini similarity index 100% rename from logging_console_config.ini rename to prom2teams/logging_console_config.ini diff --git a/logging_file_config.ini b/prom2teams/logging_file_config.ini similarity index 100% rename from logging_file_config.ini rename to prom2teams/logging_file_config.ini diff --git a/app/message/__init__.py b/prom2teams/message/__init__.py similarity index 100% rename from app/message/__init__.py rename to prom2teams/message/__init__.py diff --git a/app/message/parser.py b/prom2teams/message/parser.py similarity index 100% rename from app/message/parser.py rename to prom2teams/message/parser.py diff --git a/app/server.py b/prom2teams/server.py similarity index 86% rename from app/server.py rename to prom2teams/server.py index 6196a7f..3a3ae97 100644 --- a/app/server.py +++ b/prom2teams/server.py @@ -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): @@ -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) @@ -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 diff --git a/app/teams/__init__.py b/prom2teams/teams/__init__.py similarity index 100% rename from app/teams/__init__.py rename to prom2teams/teams/__init__.py diff --git a/app/teams/client.py b/prom2teams/teams/client.py similarity index 100% rename from app/teams/client.py rename to prom2teams/teams/client.py diff --git a/app/teams/exceptions.py b/prom2teams/teams/exceptions.py similarity index 100% rename from app/teams/exceptions.py rename to prom2teams/teams/exceptions.py diff --git a/app/teams/json_composer.py b/prom2teams/teams/json_composer.py similarity index 100% rename from app/teams/json_composer.py rename to prom2teams/teams/json_composer.py diff --git a/app/teams/template.j2 b/prom2teams/teams/template.j2 similarity index 100% rename from app/teams/template.j2 rename to prom2teams/teams/template.j2 diff --git a/setup.py b/setup.py index d6563a2..9714e97 100644 --- a/setup.py +++ b/setup.py @@ -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, @@ -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='labs@idealista.com', diff --git a/tests/context.py b/tests/context.py index 2a7a196..dd02872 100644 --- a/tests/context.py +++ b/tests/context.py @@ -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 diff --git a/tests/test_server.py b/tests/test_server.py index d39828b..bb73161 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -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'