@@ -78,9 +78,11 @@ def __call__(self, event): # noqa: D102
7878
7979 if isinstance (data , JobEnded ):
8080 # Skip if the log path is /dev/null
81- if get_log_path () is None :
82- return
81+ # => is unable to get directory
8382 base_path = get_log_directory (job )
83+ if base_path is None :
84+ return
85+
8486 for filename in all_log_filenames :
8587 path = base_path / filename
8688 if path in self ._file_handles :
@@ -115,7 +117,11 @@ def __call__(self, event): # noqa: D102
115117 # use the same encoding as the default for the opened file
116118 line = line .encode (encoding = locale .getpreferredencoding (False ))
117119
120+ # Get base path, and return if fails
118121 base_path = get_log_directory (job )
122+ if base_path is None :
123+ return
124+
119125 for filename in filenames :
120126 h = self ._file_handles [base_path / filename ]
121127
@@ -144,14 +150,17 @@ def _init_logs(self, job):
144150 if job in self ._jobs :
145151 return True
146152
147- log_path = get_log_path ()
148- if log_path is None :
153+ # Get directory
154+ # If this fails, the log directory is /dev/null
155+ # so function must return with negative result
156+ base_path = get_log_directory (job )
157+ if base_path is None :
149158 return False
150159
151160 self ._jobs .add (job )
152161
153162 create_log_path (self .context .args .verb_name )
154- base_path = get_log_directory ( job )
163+
155164 os .makedirs (str (base_path ), exist_ok = True )
156165 for filename in all_log_filenames :
157166 path = base_path / filename
@@ -166,4 +175,7 @@ def get_log_directory(job):
166175 :param job: The job
167176 :rtype: Path
168177 """
169- return get_log_path () / job .identifier
178+ log_path = get_log_path ()
179+ if log_path is None :
180+ return None
181+ return log_path / job .identifier
0 commit comments