diff --git a/cometblue/cli.py b/cometblue/cli.py index 3ec1e5d..ae1179a 100644 --- a/cometblue/cli.py +++ b/cometblue/cli.py @@ -6,6 +6,7 @@ import itertools import json import logging +import os import sys import click @@ -455,7 +456,7 @@ def _device(ctx, address, pin, pin_file): show_default=True, default='error') @click.pass_context -def main(ctx, adapter, channel_type, security_level, formatter, log_level): +def _main(ctx, adapter, channel_type, security_level, formatter, log_level): _configure_logger(_get_log_level(log_level)) ctx.obj.adapter = adapter @@ -469,6 +470,8 @@ def main(ctx, adapter, channel_type, security_level, formatter, log_level): else: ctx.obj.formatter = _ShellVarFormatter() + return os.EX_OK + class _SetterFunctions(object): @staticmethod @@ -619,13 +622,13 @@ def real_set_fn(ctx, value): _device_set.add_command(set_fn) -if __name__ == '__main__': +def main(): _configure_logger() _add_values() - main.add_command(_discover) - main.add_command(_device) + _main.add_command(_discover) + _main.add_command(_device) _device.add_command(_device_get) _device.add_command(_device_set) @@ -636,4 +639,8 @@ def real_set_fn(ctx, value): _device_set.add_command(_device_set_day) _device_set.add_command(_device_set_holiday) - main(obj=_ContextObj()) + return _main(obj=_ContextObj()) + + +if __name__ == '__main__': + exit(main()) diff --git a/requirements.txt b/requirements.txt index db07ed8..06d3fc4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,6 @@ click gattlib +pbr shellescape six tabulate diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..a2e6354 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,18 @@ +[metadata] +name = cometblue +summary = Command line tool for "Comet Blue" radiator thermostat +author = Ivan Mironov +author-email = mironov.ivan@gmail.com +home-page = https://localhost/ + +[global] +setup-hooks = + pbr.hooks.setup_hook + +[files] +packages = + cometblue + +[entry_points] +console_scripts = + cometblue = cometblue.cli:main diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..b89487e --- /dev/null +++ b/setup.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import setuptools + + +setuptools.setup( + setup_requires=['pbr'], + pbr=True)