Compare commits
3 commits
a3b0ea5436
...
426d70672a
Author | SHA1 | Date | |
---|---|---|---|
426d70672a | |||
87725686bc | |||
40faac8a07 |
9 changed files with 40 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
|||
[bumpversion]
|
||||
current_version = 0.0.1
|
||||
current_version = 0.1.0
|
||||
commit = True
|
||||
tag = True
|
||||
|
||||
|
|
|
@ -2,3 +2,4 @@ grpcio-tools~=1.43.0
|
|||
mypy-protobuf~=3.2.0
|
||||
types-protobuf~=3.19.6
|
||||
grpc-stubs~=1.24.7
|
||||
bump2version
|
||||
|
|
2
setup.py
2
setup.py
|
@ -6,7 +6,7 @@ with open('README.rst') as f:
|
|||
|
||||
setuptools.setup(
|
||||
name='TSGRain Controller',
|
||||
version='0.0.1',
|
||||
version='0.1.0',
|
||||
author='ThetaDev',
|
||||
description='TSGRain irrigation controller',
|
||||
long_description=README,
|
||||
|
|
|
@ -34,7 +34,7 @@ def app(mocker):
|
|||
return_value=fixtures.TestingIo())
|
||||
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
app = application.Application(io_factory.IoType.VOID, td,
|
||||
app = application.Application(io_factory.IoType.NONE, td,
|
||||
fixtures.FILE_CFG)
|
||||
|
||||
assert not app.is_running()
|
||||
|
|
|
@ -37,7 +37,7 @@ def app(mocker):
|
|||
return_value=fixtures.TestingIo())
|
||||
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
app = application.Application(io_factory.IoType.VOID, td,
|
||||
app = application.Application(io_factory.IoType.NONE, td,
|
||||
fixtures.FILE_CFG)
|
||||
assert not app.is_running()
|
||||
app.start()
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = '0.0.1'
|
||||
__version__ = '0.1.0'
|
||||
|
|
|
@ -2,25 +2,46 @@ import signal
|
|||
import sys
|
||||
import os
|
||||
import traceback
|
||||
import argparse
|
||||
import pathlib
|
||||
|
||||
from tsgrain_controller import __version__, application
|
||||
from tsgrain_controller.io import io_factory
|
||||
|
||||
|
||||
def _get_io_types() -> str:
|
||||
io_types = [t.name for t in io_factory.IoType]
|
||||
return '|'.join(io_types)
|
||||
|
||||
|
||||
def _parse_args():
|
||||
parser = argparse.ArgumentParser(description='TSGRain Controller')
|
||||
parser.add_argument('-c, --config',
|
||||
dest='cfg',
|
||||
type=pathlib.Path,
|
||||
help='Pfad der Konfigurationsdatei')
|
||||
|
||||
parser.add_argument('--io', dest='io', help=f'IO-Typ: {_get_io_types()}')
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def run():
|
||||
print(f'TSGRain Controller {__version__}\n')
|
||||
args = _parse_args()
|
||||
|
||||
io_type = io_factory.IoType.MCP23017
|
||||
if args.io:
|
||||
try:
|
||||
io_type = io_factory.IoType[args.io.upper()]
|
||||
except KeyError:
|
||||
print(f'IO-Typ {args.io} ungültig. Verwende {_get_io_types()}')
|
||||
sys.exit(1)
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
arg1 = sys.argv[1]
|
||||
if arg1.startswith('c'):
|
||||
io_type = io_factory.IoType.CONSOLE
|
||||
cfg_path = None
|
||||
if args.cfg:
|
||||
cfg_path = args.cfg.name
|
||||
|
||||
if arg1.startswith('v'):
|
||||
io_type = io_factory.IoType.VOID
|
||||
|
||||
app = application.Application(io_type)
|
||||
app = application.Application(io_type, cfg_path=cfg_path)
|
||||
|
||||
def _signal_handler(sig, frame): # pylint: disable=unused-argument
|
||||
app.stop()
|
||||
|
|
|
@ -20,11 +20,14 @@ class Application(models.AppInterface):
|
|||
cfg_path = os.path.join(workdir, 'tsgrain.toml')
|
||||
|
||||
self.logger = logging.getLogger()
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
self.logger.setLevel(logging.INFO)
|
||||
|
||||
self.cfg = config.Config(cfg_path)
|
||||
self.cfg.load_file()
|
||||
|
||||
if self.cfg.log_debug:
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
|
||||
if self.cfg.db_path:
|
||||
db_path = self.cfg.db_path
|
||||
else:
|
||||
|
|
|
@ -4,7 +4,7 @@ from tsgrain_controller import models, io
|
|||
|
||||
|
||||
class IoType(Enum):
|
||||
VOID = 0
|
||||
NONE = 0
|
||||
CONSOLE = 1
|
||||
MCP23017 = 2
|
||||
|
||||
|
|
Loading…
Reference in a new issue