From a62e05c9564045044df734fd3723b3f665ad91ae Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 29 Dec 2017 06:43:49 +0100 Subject: DPD: Make logging to file optional in all modules, simplify apply_adapt_dumps --- dpd/src/Adapt.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'dpd/src/Adapt.py') diff --git a/dpd/src/Adapt.py b/dpd/src/Adapt.py index 7e19a2c..c78c920 100644 --- a/dpd/src/Adapt.py +++ b/dpd/src/Adapt.py @@ -16,7 +16,10 @@ import os import datetime import pickle -logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFilename) +try: + logging_path = os.path.dirname(logging.getLoggerClass().root.handlers[0].baseFilename) +except AttributeError: + logging_path = None LUT_LEN = 32 FORMAT_POLY = 1 @@ -226,7 +229,10 @@ class Adapt: """Backup current settings to a file""" dt = datetime.datetime.now().isoformat() if path is None: - path = logging_path + "/" + dt + "_adapt.pkl" + if logging_path is not None: + path = logging_path + "/" + dt + "_adapt.pkl" + else: + raise Exception("Cannot dump Adapt without either logging_path or path set") d = { "txgain": self.get_txgain(), "rxgain": self.get_rxgain(), -- cgit v1.2.3