add history writer

Change-Id: I2d577dcf0c543c26680d157be959b0a608ace759
This commit is contained in:
2020-12-10 17:04:41 +01:00
parent 16834f8802
commit e0f9b4a858
2 changed files with 117 additions and 1 deletions

View File

@ -42,6 +42,7 @@ except ImportError:
from secop.errors import ConfigError
from secop.lib import formatException, get_class, getGeneralConfig
from secop.modules import Attached
from secop.params import PREDEFINED_ACCESSIBLES
try:
import systemd.daemon
@ -126,7 +127,7 @@ class Server:
else:
filename = None
if filename is None:
raise ConfigError("Couldn't find cfg file %r" % cfgfile)
raise ConfigError("Couldn't find cfg file %r in %s" % (cfgfile, cfg['confdir']))
self.log.debug('Parse config file %s ...' % filename)
result = OrderedDict()
parser = configparser.ConfigParser()
@ -270,3 +271,10 @@ class Server:
if not event.wait(timeout=max(0, deadline - time.time())):
self.log.info('WARNING: timeout when starting %s' % name)
self.log.info('all modules and pollers started')
history_path = os.environ.get('FRAPPY_HISTORY')
if history_path:
from secop.histwriter import HistWriter
writer = HistWriter(history_path, PREDEFINED_ACCESSIBLES.keys(), self.dispatcher)
# treat writer as a connection
self.dispatcher.add_connection(writer)
writer.init(self.dispatcher.handle_describe(writer, None, None))