check isfile before opening
This commit is contained in:
parent
18106eaa96
commit
9f4a145e48
|
@ -119,6 +119,8 @@ class Logger:
|
||||||
show = nick
|
show = nick
|
||||||
for f in files:
|
for f in files:
|
||||||
path_to_file = os.path.join(LOGPATH, f)
|
path_to_file = os.path.join(LOGPATH, f)
|
||||||
|
if not os.path.isfile(path_to_file):
|
||||||
|
return
|
||||||
fil = open(path_to_file, 'a')
|
fil = open(path_to_file, 'a')
|
||||||
fil.write('%s:%s:%s' % (tim, jid, show))
|
fil.write('%s:%s:%s' % (tim, jid, show))
|
||||||
if msg:
|
if msg:
|
||||||
|
@ -140,7 +142,7 @@ class Logger:
|
||||||
'''return total number of lines in a log file
|
'''return total number of lines in a log file
|
||||||
return 0 if log file does not exist'''
|
return 0 if log file does not exist'''
|
||||||
path_to_file = self.__get_path_to_file(fjid)
|
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
|
return 0
|
||||||
fil = open(path_to_file, 'r')
|
fil = open(path_to_file, 'r')
|
||||||
no_of_lines = 0 # number of lines
|
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 number of lines read and the text in the lines
|
||||||
return 0 and empty respectively if log file does not exist'''
|
return 0 and empty respectively if log file does not exist'''
|
||||||
path_to_file = self.__get_path_to_file(fjid)
|
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, []
|
return 0, []
|
||||||
fil = open(path_to_file, 'r')
|
fil = open(path_to_file, 'r')
|
||||||
no_of_lines = 0 # number of lines
|
no_of_lines = 0 # number of lines
|
||||||
|
|
Loading…
Reference in New Issue