Compare commits

..

No commits in common. "426d70672aded9b6790e814372c2047fdf2f728c" and "a3b0ea5436d6a0864df7bd12513f116bc7366c85" have entirely different histories.

9 changed files with 15 additions and 40 deletions

View file

@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.1.0
current_version = 0.0.1
commit = True
tag = True

View file

@ -2,4 +2,3 @@ grpcio-tools~=1.43.0
mypy-protobuf~=3.2.0
types-protobuf~=3.19.6
grpc-stubs~=1.24.7
bump2version

View file

@ -6,7 +6,7 @@ with open('README.rst') as f:
setuptools.setup(
name='TSGRain Controller',
version='0.1.0',
version='0.0.1',
author='ThetaDev',
description='TSGRain irrigation controller',
long_description=README,

View file

@ -34,7 +34,7 @@ def app(mocker):
return_value=fixtures.TestingIo())
with tempfile.TemporaryDirectory() as td:
app = application.Application(io_factory.IoType.NONE, td,
app = application.Application(io_factory.IoType.VOID, td,
fixtures.FILE_CFG)
assert not app.is_running()

View file

@ -37,7 +37,7 @@ def app(mocker):
return_value=fixtures.TestingIo())
with tempfile.TemporaryDirectory() as td:
app = application.Application(io_factory.IoType.NONE, td,
app = application.Application(io_factory.IoType.VOID, td,
fixtures.FILE_CFG)
assert not app.is_running()
app.start()

View file

@ -1 +1 @@
__version__ = '0.1.0'
__version__ = '0.0.1'

View file

@ -2,46 +2,25 @@ 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)
cfg_path = None
if args.cfg:
cfg_path = args.cfg.name
if len(sys.argv) > 1:
arg1 = sys.argv[1]
if arg1.startswith('c'):
io_type = io_factory.IoType.CONSOLE
app = application.Application(io_type, cfg_path=cfg_path)
if arg1.startswith('v'):
io_type = io_factory.IoType.VOID
app = application.Application(io_type)
def _signal_handler(sig, frame): # pylint: disable=unused-argument
app.stop()

View file

@ -20,14 +20,11 @@ class Application(models.AppInterface):
cfg_path = os.path.join(workdir, 'tsgrain.toml')
self.logger = logging.getLogger()
self.logger.setLevel(logging.INFO)
self.logger.setLevel(logging.DEBUG)
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:

View file

@ -4,7 +4,7 @@ from tsgrain_controller import models, io
class IoType(Enum):
NONE = 0
VOID = 0
CONSOLE = 1
MCP23017 = 2