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/phase_align.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'dpd/src/phase_align.py') diff --git a/dpd/src/phase_align.py b/dpd/src/phase_align.py index 68c216d..21a210c 100644 --- a/dpd/src/phase_align.py +++ b/dpd/src/phase_align.py @@ -7,7 +7,10 @@ import datetime import os import logging -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 import numpy as np import matplotlib.pyplot as plt @@ -24,7 +27,7 @@ def phase_align(sig, ref_sig, plot=False): real_diffs = np.cos(angle_diff) imag_diffs = np.sin(angle_diff) - if logging.getLogger().getEffectiveLevel() == logging.DEBUG and plot: + if logging.getLogger().getEffectiveLevel() == logging.DEBUG and plot and logging_path is not None: dt = datetime.datetime.now().isoformat() fig_path = logging_path + "/" + dt + "_phase_align.svg" -- cgit v1.2.3