From 9f4a145e485d801a28473a41d67d0e896f56d768 Mon Sep 17 00:00:00 2001 From: Nikos Kouremenos Date: Sun, 14 Aug 2005 21:46:57 +0000 Subject: [PATCH] check isfile before opening --- src/common/logger.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/logger.py b/src/common/logger.py index da8a98973..5d0fdb92f 100644 --- a/src/common/logger.py +++ b/src/common/logger.py @@ -119,6 +119,8 @@ class Logger: show = nick for f in files: path_to_file = os.path.join(LOGPATH, f) + if not os.path.isfile(path_to_file): + return fil = open(path_to_file, 'a') fil.write('%s:%s:%s' % (tim, jid, show)) if msg: @@ -140,7 +142,7 @@ class Logger: '''return total number of lines in a log file return 0 if log file does not exist''' path_to_file = self.__get_path_to_file(fjid) - if not os.path.exists(path_to_file): + if not os.path.isfile(path_to_file): return 0 fil = open(path_to_file, 'r') no_of_lines = 0 # number of lines @@ -153,7 +155,7 @@ class Logger: '''return number of lines read and the text in the lines return 0 and empty respectively if log file does not exist''' path_to_file = self.__get_path_to_file(fjid) - if not os.path.exists(path_to_file): + if not os.path.isfile(path_to_file): return 0, [] fil = open(path_to_file, 'r') no_of_lines = 0 # number of lines