From 1b543e582031d722966641daaa6ca3ad04c13562 Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 27 Jul 2020 18:55:59 +0200 Subject: [PATCH 1/2] Dont crash when journal_dir is None Ensures that journal_dir is always at least an empty string. Fixes #639 --- monitor.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/monitor.py b/monitor.py index eb63e83c..ac7e8d10 100644 --- a/monitor.py +++ b/monitor.py @@ -118,9 +118,14 @@ class EDLogs(FileSystemEventHandler): def start(self, root): self.root = root - logdir = expanduser(config.get('journaldir') or config.default_journal_dir) # type: ignore # config is weird + journal_dir = config.get('journaldir') or config.default_journal_dir - if not logdir or not isdir(logdir): # type: ignore # config does weird things in its get + if journal_dir is None: + journal_dir = '' + + logdir = expanduser(journal_dir) # type: ignore # config is weird + + if not logdir or not isdir(logdir): self.stop() return False From 6ab4433c590ee1deaec02a004aaf2a8cad838b93 Mon Sep 17 00:00:00 2001 From: A_D Date: Mon, 27 Jul 2020 19:07:54 +0200 Subject: [PATCH 2/2] Add TODO regarding type config --- monitor.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monitor.py b/monitor.py index ac7e8d10..90988dfd 100644 --- a/monitor.py +++ b/monitor.py @@ -122,7 +122,9 @@ class EDLogs(FileSystemEventHandler): if journal_dir is None: journal_dir = '' - + + # TODO(A_D): this is ignored for type checking due to all the different types config.get returns + # When that is refactored, remove the magic comment logdir = expanduser(journal_dir) # type: ignore # config is weird if not logdir or not isdir(logdir):