From 4fd9c17bcb3393d68e0b9912e3502594038cc8a3 Mon Sep 17 00:00:00 2001 From: Markus Zolliker Date: Mon, 1 Mar 2021 09:24:20 +0100 Subject: [PATCH] move historywriter to secop_psi as historywriter currently could be used at psi only secop_psi is a better place for it + add comment about a general config file Change-Id: I9b0e74d3da83ac485bd4bcc13475695c3140822c Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/25077 Tested-by: Jenkins Automated Tests Reviewed-by: Enrico Faulhaber Reviewed-by: Markus Zolliker --- secop/lib/__init__.py | 3 +++ secop/server.py | 10 +++++++++- {secop => secop_psi}/historywriter.py | 0 3 files changed, 12 insertions(+), 1 deletion(-) rename {secop => secop_psi}/historywriter.py (100%) diff --git a/secop/lib/__init__.py b/secop/lib/__init__.py index ad3df26..8118f24 100644 --- a/secop/lib/__init__.py +++ b/secop/lib/__init__.py @@ -52,9 +52,12 @@ else: # overwrite with env variables SECOP_LOGDIR, SECOP_PIDDIR, SECOP_CONFDIR, if present for dirname in CONFIG: CONFIG[dirname] = environ.get('SECOP_%s' % dirname.upper(), CONFIG[dirname]) + # this is not customizable CONFIG['basedir'] = repodir +# TODO: if ever more general options are need, we should think about a general config file + unset_value = object() diff --git a/secop/server.py b/secop/server.py index d7f8db0..cde2ff8 100644 --- a/secop/server.py +++ b/secop/server.py @@ -275,8 +275,16 @@ class Server: self.log.info('all modules and pollers started') history_path = os.environ.get('FRAPPY_HISTORY') if history_path: - from secop.historywriter import FrappyHistoryWriter # pylint: disable=import-outside-toplevel + from secop_psi.historywriter import FrappyHistoryWriter # pylint: disable=import-outside-toplevel writer = FrappyHistoryWriter(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)) + # TODO: if ever somebody wants to implement an other history writer: + # - a general config file /etc/secp/secop.conf or /etc/secop.conf + # might be introduced, which contains the log, pid and cfg directory path and + # the class path implementing the history + # - or we just add here an other if statement: + # history_path = os.environ.get('ALTERNATIVE_HISTORY') + # if history_path: + # from secop_.historywriter import ... etc. diff --git a/secop/historywriter.py b/secop_psi/historywriter.py similarity index 100% rename from secop/historywriter.py rename to secop_psi/historywriter.py