From b4dfa8d83597e3a9cb1edcc5060b0ad90daf39ce Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Fri, 16 Feb 2018 09:48:26 -0800 Subject: [PATCH] Switch to setup.py --- README.md | 9 ++++++- minitor/main.py | 12 ++++++++- requirements.txt | 1 - setup.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 3 deletions(-) delete mode 100644 requirements.txt create mode 100644 setup.py diff --git a/README.md b/README.md index 18c2049..0dc3ab4 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,14 @@ I'm running a few small services and found Sensu, Consul, Nagios, etc. to all be ### Running -Eventually it will be installed as python package, but for now: +Install and execute with: + +``` +pip install -e git+https://git.iamthefij.com/iamthefij/minitor.git#egg=minitor +minitor +``` + +If locally developing you can use: ``` make run diff --git a/minitor/main.py b/minitor/main.py index 7c628dd..9b02a82 100644 --- a/minitor/main.py +++ b/minitor/main.py @@ -1,3 +1,4 @@ +import sys from argparse import ArgumentParser from datetime import datetime from os import environ @@ -223,5 +224,14 @@ class Minitor(object): sleep(self.check_interval) + +def main(): + try: + Minitor().run() + except KeyboardInterrupt: + pass + return 0 + + if __name__ == '__main__': - Minitor().run() + sys.exit(main()) diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index e315c16..0000000 --- a/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -yamlenv diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..6a03163 --- /dev/null +++ b/setup.py @@ -0,0 +1,68 @@ +"""A setuptools based setup module. + +See: +https://packaging.python.org/en/latest/distributing.html +https://github.com/pypa/sampleproject +""" + +# Always prefer setuptools over distutils +from setuptools import setup, find_packages +# To use a consistent encoding +from codecs import open +from os import path + +here = path.abspath(path.dirname(__file__)) + +# Get the long description from the README file +with open(path.join(here, 'README.md'), encoding='utf-8') as f: + long_description = f.read() + +# Arguments marked as "Required" below must be included for upload to PyPI. +# Fields marked as "Optional" may be commented out. + +setup( + name='minitor', + version='0.1.0', + description='A minimal monitoring tool', + long_description=long_description, + url='https://git.iamthefij.com/iamthefij/minitor', + author='Ian Fijolek', + author_email='ian@iamthefij.com', + # Classifiers help users find your project by categorizing it. + # + # For a list of valid classifiers, see + # https://pypi.python.org/pypi?%3Aaction=list_classifiers + classifiers=[ + # How mature is this project? Common values are + # 3 - Alpha + # 4 - Beta + # 5 - Production/Stable + 'Development Status :: 3 - Alpha', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Topic :: System :: Monitoring', + 'License :: OSI Approved :: Apache Software License', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + ], + keywords='minitor monitoring alerting', + packages=find_packages(exclude=['contrib', 'docs', 'tests']), # Required + install_requires=[ + 'yamlenv', + ], + + # To provide executable scripts, use entry points in preference to the + # "scripts" keyword. Entry points provide cross-platform support and allow + # `pip` to create the appropriate form of executable for the target + # platform. + # + # For example, the following would provide a command called `sample` which + # executes the function `main` from this package when invoked: + entry_points={ + 'console_scripts': [ + 'minitor=minitor.main:main', + ], + }, +)