Merge pull request #485 from YunoHost/check_if_log_exists_before_tailing

[fix] check if log exists before tailing to avoid errors
This commit is contained in:
Bram 2018-06-05 21:47:00 +02:00 committed by GitHub
commit 3be951bdd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -326,7 +326,7 @@ def service_log(name, number=50):
for log_path in log_list:
# log is a file, read it
if not os.path.isdir(log_path):
result[log_path] = _tail(log_path, int(number))
result[log_path] = _tail(log_path, int(number)) if os.path.exists(log_path) else []
continue
for log_file in os.listdir(log_path):
@ -338,7 +338,7 @@ def service_log(name, number=50):
if not log_file.endswith(".log"):
continue
result[log_file_path] = _tail(log_file_path, int(number))
result[log_file_path] = _tail(log_file_path, int(number)) if os.path.exists(log_file_path) else []
return result