@@ -53,6 +53,7 @@ def emit(self, record):
5353
5454 # A posix system could be a MacOS or a Linux variety
5555 if system == PLATFORM_POSIX :
56+ # Asking for a MacOS version number only works on MacOS
5657 is_mac = platform .mac_ver ()
5758 if is_mac [0 ] == "" :
5859 # This must be a Linux platform
@@ -110,8 +111,10 @@ def __set_linux_logpath(filename):
110111 # Does the log directory exist
111112 try :
112113 result = __verify_logpath (log_path )
113- if result is None and __create_logpath (log_path ) is None :
114- return None
114+ if result is None or result == False :
115+ # Path does not exist. Create it
116+ if __create_logpath (log_path ) is None :
117+ return None
115118 else :
116119 return log_path + '/' + filename
117120
@@ -129,12 +132,14 @@ def __set_macos_logpath(filename):
129132 # Does the log directory exist
130133 try :
131134 result = __verify_logpath (log_path )
132- if result is None and __create_logpath (log_path ) is None :
133- # Try to create the directory in the tmp directory
134- log_path = '/tmp'
135- result = __verify_logpath (log_path )
136- if result is None :
137- return None
135+ if result is None or result == False :
136+ # Path does not exist. Let's create it
137+ if __create_logpath (log_path ) is None :
138+ # Try to create the directory in the tmp directory
139+ log_path = '/tmp'
140+ result = __verify_logpath (log_path )
141+ if result is None :
142+ return None
138143
139144 return log_path + '/' + filename
140145 except OSError :
@@ -152,13 +157,15 @@ def __set_windows_logpath(filename):
152157 try :
153158 result = __verify_logpath (log_path )
154159
155- if result is None and __create_logpath (log_path ) is None :
156- # try to create the log file in the user's home directory
157- log_path = user_home
158- result = __verify_logpath (log_path )
160+ if result is None or result == False :
161+ # Path does not exist. Create it
162+ if __create_logpath (log_path ) is None :
163+ # try to create the log file in the user's home directory
164+ log_path = user_home
165+ result = __verify_logpath (log_path )
159166
160- if result is None :
161- return None
167+ if result is None :
168+ return None
162169
163170 return log_path + '/' + filename
164171 except OSError :
@@ -169,7 +176,8 @@ def __set_windows_logpath(filename):
169176def __create_logpath (file_path ):
170177 try :
171178 os .makedirs (file_path )
172- return path
179+ return True
180+
173181 except OSError as ex :
174182 print ex .message
175183 return None
@@ -179,11 +187,12 @@ def __create_logpath(file_path):
179187def __verify_logpath (file_path ):
180188 try :
181189 print ("Testing access to: %s" , file_path )
182- info = os .access (file_path , os .W_OK )
183- return info
190+ return os .access (file_path , os .W_OK )
191+
184192 except OSError as ex :
185193 print ex .message
186194 return None
195+
187196 except Exception as ex :
188197 print ex .message
189198 return None
0 commit comments