Compare commits
No commits in common. "426d70672aded9b6790e814372c2047fdf2f728c" and "a3b0ea5436d6a0864df7bd12513f116bc7366c85" have entirely different histories.
426d70672a
...
a3b0ea5436
9 changed files with 15 additions and 40 deletions
|
@ -1,5 +1,5 @@
|
|||
[bumpversion]
|
||||
current_version = 0.1.0
|
||||
current_version = 0.0.1
|
||||
commit = True
|
||||
tag = True
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
2
setup.py
2
setup.py
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = '0.1.0'
|
||||
__version__ = '0.0.1'
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -4,7 +4,7 @@ from tsgrain_controller import models, io
|
|||
|
||||
|
||||
class IoType(Enum):
|
||||
NONE = 0
|
||||
VOID = 0
|
||||
CONSOLE = 1
|
||||
MCP23017 = 2
|
||||
|
||||
|
|
Loading…
Reference in a new issue