1
0
mirror of https://github.com/binary-kitchen/doorlockd synced 2024-12-06 20:20:33 +01:00

Config: Move SYSCONFDIR and PREFIX to Config

Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
Ralf Ramsauer 2019-06-15 20:00:25 +02:00
parent 1e5f7c3ec4
commit 9828534eae
3 changed files with 13 additions and 12 deletions

View File

@ -11,8 +11,8 @@ SYSTEMD_UNITS = $(ETC)/systemd/system/
all: gpio-wait pydoorlock/Protocol.py
package:
sed -i -r -e "s@(^SYSCONFDIR = ').*('$$)@\1$(SYSCONFDIR)\2@" doorlockd
sed -i -r -e "s@(^PREFIX = ').*('$$)@\1$(PREFIX)\2@" doorlockd
sed -i -r -e "s@(^SYSCONFDIR = ').*('$$)@\1$(SYSCONFDIR)\2@" pydoorlock/Config.py
sed -i -r -e "s@(^PREFIX = ').*('$$)@\1$(PREFIX)\2@" pydoorlock/Config.py
sed -i -r -e "s@(^__version__ = ').*('$$)@\1$(shell cat VERSION)\2@" doorlockd
pydoorlock/Protocol.py: avr-code/protocol.h

View File

@ -26,10 +26,7 @@ from os.path import abspath, join
from pydoorlock.Authenticator import Authenticator
from pydoorlock.WebApp import webapp_run, emit_doorstate
from pydoorlock.Doorlock import DoorlockResponse, DoorHandler
from pydoorlock.Config import Config
SYSCONFDIR = './etc'
PREFIX = '.'
from pydoorlock.Config import Config, root_prefix, sounds_prefix
__author__ = 'Ralf Ramsauer'
__copyright = 'Copyright (c) Ralf Ramsauer, 2018-2019'
@ -44,7 +41,7 @@ date_fmt = '%Y-%m-%d %H:%M:%S'
log_fmt = '%(asctime)-15s %(levelname)-8s %(message)s'
log = logging.getLogger()
cfg = Config(SYSCONFDIR, 'doorlockd')
cfg = Config('doorlockd')
class Logic:
@ -70,9 +67,6 @@ if __name__ == '__main__':
format=log_fmt, datefmt=date_fmt)
log.info('Starting doorlockd')
root_prefix = join(PREFIX, 'share', 'doorlockd')
sounds_prefix = join(root_prefix, 'sounds')
scripts_prefix = join(root_prefix, 'scripts')
logic = Logic(cfg, sounds_prefix, scripts_prefix, emit_doorstate)

View File

@ -21,6 +21,13 @@ from configparser import ConfigParser
from os.path import join
SYSCONFDIR = './etc'
PREFIX = '.'
root_prefix = join(PREFIX, 'share', 'doorlockd')
sounds_prefix = join(root_prefix, 'sounds')
def check_exists(func):
@functools.wraps(func)
def decorator(*args, **kwargs):
@ -32,10 +39,10 @@ def check_exists(func):
class Config:
def __init__(self, sysconfdir, config_topic):
def __init__(self, config_topic):
self.config_topic = config_topic
self.config = ConfigParser()
self.config.read(join(sysconfdir, 'doorlockd.cfg'))
self.config.read(join(SYSCONFDIR, 'doorlockd.cfg'))
@check_exists
def boolean(self, key):