From ff12af70d846e755447c76d247d387a33307c106 Mon Sep 17 00:00:00 2001 From: Alexander Werner Date: Thu, 22 Nov 2018 20:47:36 +0100 Subject: [PATCH] added production commands and final config structure --- carom/cli.py | 16 +++++++++++++++- carom/client.ini | 16 ++++++++++++++-- carom/config.py | 13 ++++++++++--- carom/const.py | 4 +--- doc/man/carom-client.1 | 28 +++++++++++++++++++++++++++- 5 files changed, 67 insertions(+), 10 deletions(-) diff --git a/carom/cli.py b/carom/cli.py index 2324b70..d892d30 100644 --- a/carom/cli.py +++ b/carom/cli.py @@ -1,3 +1,5 @@ +import uuid + import click from click_didyoumean import DYMGroup import click_log @@ -13,6 +15,19 @@ click_log.basic_config(root_logger) def cli(): pass +@cli.command() +def get_gpio(): + """ + Get the current status of all Tables. + """ + pass + +@cli.command() +def get_uuid(): + """ + Get the UUID of the Client. This is need to add a new client to the carom server installation. + """ + click.echo(uuid.uuid5(uuid.NAMESPACE_DNS, str(uuid.getnode()))) @cli.command() def run(): @@ -21,7 +36,6 @@ def run(): """ pass - @cli.command() def check_config(): """ diff --git a/carom/client.ini b/carom/client.ini index 2c6062d..0199146 100644 --- a/carom/client.ini +++ b/carom/client.ini @@ -1,2 +1,14 @@ -[test] -foo = bar \ No newline at end of file +[connection] +endpoint = https://carom.einsle.de/{0} +token = +[mapping] +20 = 1 +16 = 2 +12 = 3 +7 = 4 +8 = 5 +25 = 6 +24 = 7 +18 = 8 +[logging] +file = /var/log/carom-client.log \ No newline at end of file diff --git a/carom/config.py b/carom/config.py index b22a1fc..6153e62 100644 --- a/carom/config.py +++ b/carom/config.py @@ -1,7 +1,7 @@ import configparser import logging -from voluptuous import Schema, Error +from voluptuous import Schema, Error, Range, All, Coerce from voluptuous.humanize import validate_with_humanized_errors from carom.const import CONFIG_FILES, DEFAULT_CONFIG @@ -14,9 +14,16 @@ _parser.read(CONFIG_FILES) # Convert the ConfigParser object to a real dict now: _parser_dict = {s: dict(_parser.items(s)) for s in _parser.sections()} _schema = Schema({ - 'test': { - 'foo': str, + 'connection': { + 'endpoint': str, + 'token': str, }, + 'mapping': { + All(Coerce(int), Range(0, 28)): All(Coerce(int), Range(1, 8)), + }, + 'logging': { + 'file': str + } }) try: diff --git a/carom/const.py b/carom/const.py index ba1804f..8c31c82 100644 --- a/carom/const.py +++ b/carom/const.py @@ -1,8 +1,6 @@ from pkg_resources import resource_string -AVAILABLE_PINS = range(0, 28) -"""Pins available for Configuration""" DEFAULT_CONFIG = resource_string(__name__, 'client.ini').decode() """Default configfile, that is used as a Fallback if no other configuration exists.""" -CONFIG_FILES = ('~/.config/carom/client.ini', '/etc/carom/client.ini') +CONFIG_FILES = ('/boot/carom-client.conf', ) """Order of resolution of Config Files. Files are tried in order, first one found is used.""" diff --git a/doc/man/carom-client.1 b/doc/man/carom-client.1 index cdf1b7c..430f113 100644 --- a/doc/man/carom-client.1 +++ b/doc/man/carom-client.1 @@ -1,6 +1,6 @@ .\" Man page generated from reStructuredText. . -.TH "CAROM-CLIENT" "1" "05.11.2018" "" "Carom Client" +.TH "CAROM-CLIENT" "1" "22.11.2018" "" "Carom Client" .SH NAME carom-client \- Carom Client Documentation . @@ -58,6 +58,32 @@ carom\-client check\-config [OPTIONS] .fi .UNINDENT .UNINDENT +.SH GET-GPIO +.sp +Get the current status of all Tables. +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +carom\-client get\-gpio [OPTIONS] +.ft P +.fi +.UNINDENT +.UNINDENT +.SH GET-UUID +.sp +Get the UUID of the Client. This is need to add a new client to the carom server installation. +.INDENT 0.0 +.INDENT 3.5 +.sp +.nf +.ft C +carom\-client get\-uuid [OPTIONS] +.ft P +.fi +.UNINDENT +.UNINDENT .SH RUN .sp This command runs the carom\-client daemon process.