mirror of
https://github.com/binary-kitchen/doorlockd
synced 2024-12-22 02:14:26 +01:00
pydoorlock: Config: Only use one config file
Signed-off-by: Ralf Ramsauer <ralf@binary-kitchen.de>
This commit is contained in:
parent
bdfcf29075
commit
a774262a3c
2
Makefile
2
Makefile
@ -22,7 +22,7 @@ install:
|
|||||||
|
|
||||||
install doorlockd gpio-wait doorstate $(DESTDIR)/$(PREFIX)/bin/
|
install doorlockd gpio-wait doorstate $(DESTDIR)/$(PREFIX)/bin/
|
||||||
install doorlockd-passwd $(DESTDIR)/$(PREFIX)/bin/
|
install doorlockd-passwd $(DESTDIR)/$(PREFIX)/bin/
|
||||||
install -m 0644 doorlockd.default.cfg doorlockd.cfg $(DESTDIR)/$(SYSCONFDIR)
|
install -m 0644 doorlockd.cfg $(DESTDIR)/$(SYSCONFDIR)
|
||||||
install -m 0644 doorlockd.service doorstate.service $(DESTDIR)/$(SYSCONFDIR)/systemd/system
|
install -m 0644 doorlockd.service doorstate.service $(DESTDIR)/$(SYSCONFDIR)/systemd/system
|
||||||
|
|
||||||
pip install --upgrade --force-reinstall --root=$(DESTDIR) .
|
pip install --upgrade --force-reinstall --root=$(DESTDIR) .
|
||||||
|
@ -1,5 +1,11 @@
|
|||||||
[doorlock]
|
[doorlock]
|
||||||
|
|
||||||
|
DEBUG = False
|
||||||
|
SIMULATE_SERIAL = False
|
||||||
|
SIMULATE_AUTH = False
|
||||||
|
RUN_HOOKS = True
|
||||||
|
SOUNDS = True
|
||||||
|
|
||||||
# LDAP
|
# LDAP
|
||||||
# LDAP_URI = ldaps://ldap1.binary.kitchen
|
# LDAP_URI = ldaps://ldap1.binary.kitchen
|
||||||
# LDAP_BINDDN = cn=%%s,ou=people,dc=binary-kitchen,dc=de
|
# LDAP_BINDDN = cn=%%s,ou=people,dc=binary-kitchen,dc=de
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
[DEFAULT]
|
|
||||||
DEBUG = False
|
|
||||||
SIMULATE_SERIAL = False
|
|
||||||
SIMULATE_AUTH = False
|
|
||||||
RUN_HOOKS = True
|
|
||||||
SOUNDS = True
|
|
||||||
|
|
||||||
LOCAL_USER_DB =
|
|
||||||
|
|
||||||
LDAP_URI =
|
|
||||||
LDAP_BINDDN =
|
|
@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Doorlockd -- Binary Kitchen's smart door opener
|
Doorlockd -- Binary Kitchen's smart door opener
|
||||||
|
|
||||||
Copyright (c) Binary Kitchen e.V., 2018
|
Copyright (c) Binary Kitchen e.V., 2018-2019
|
||||||
|
|
||||||
Author:
|
Author:
|
||||||
Ralf Ramsauer <ralf@binary-kitchen.de>
|
Ralf Ramsauer <ralf@binary-kitchen.de>
|
||||||
@ -16,22 +16,36 @@ FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|||||||
details.
|
details.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import functools
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
from os.path import join
|
from os.path import join
|
||||||
|
|
||||||
|
|
||||||
|
def check_exists(func):
|
||||||
|
@functools.wraps(func)
|
||||||
|
def decorator(*args, **kwargs):
|
||||||
|
config = args[0]
|
||||||
|
if not config.config.has_option(config.config_topic, args[1]):
|
||||||
|
return None
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
config_topic = 'doorlock'
|
config_topic = 'doorlock'
|
||||||
|
|
||||||
def __init__(self, sysconfdir):
|
def __init__(self, sysconfdir):
|
||||||
self.config = ConfigParser()
|
self.config = ConfigParser()
|
||||||
self.config.read([join(sysconfdir, 'doorlockd.default.cfg'),
|
self.config.read(join(sysconfdir, 'doorlockd.cfg'))
|
||||||
join(sysconfdir, 'doorlockd.cfg')])
|
|
||||||
|
|
||||||
|
@check_exists
|
||||||
def boolean(self, key):
|
def boolean(self, key):
|
||||||
return self.config.getboolean(self.config_topic, key)
|
return self.config.getboolean(self.config_topic, key)
|
||||||
|
|
||||||
|
@check_exists
|
||||||
def str(self, key):
|
def str(self, key):
|
||||||
return self.config.get(self.config_topic, key)
|
return self.config.get(self.config_topic, key)
|
||||||
|
|
||||||
|
@check_exists
|
||||||
def int(self,key):
|
def int(self,key):
|
||||||
return self.config.getint(self.config_topic, key)
|
return self.config.getint(self.config_topic, key)
|
||||||
|
Loading…
Reference in New Issue
Block a user