Skip to content

Permission error exception on log files not caught

When a the log files exists and for some reason is not accessible by the current user PermissionError, then this exception is not caught. An example from the output is:

Traceback (most recent call last):
  File "/usr/lib64/python3.7/logging/config.py", line 562, in configure
    handler = self.configure_handler(handlers[name])
  File "/usr/lib64/python3.7/logging/config.py", line 735, in configure_handler
    result = factory(**kwargs)
  File "/home/radioastronomy/radioTelescopeProgram/pc-gui-app/Core/Handlers/CLogFileHandler.py", line 30, in __init__
    filename, when, backupCount=backup_count, encoding=enc, utc=utc)
  File "/usr/lib64/python3.7/logging/handlers.py", line 199, in __init__
    BaseRotatingHandler.__init__(self, filename, 'a', encoding, delay)
  File "/usr/lib64/python3.7/logging/handlers.py", line 54, in __init__
    logging.FileHandler.__init__(self, filename, mode, encoding, delay)
  File "/usr/lib64/python3.7/logging/__init__.py", line 1092, in __init__
    StreamHandler.__init__(self, self._open())
  File "/usr/lib64/python3.7/logging/__init__.py", line 1121, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
PermissionError: [Errno 13] Permission denied: '/home/radioastronomy/radioTelescopeProgram/pc-gui-app/logs/RadioTelescope_Logger.log'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "Core/./RadioTele_PC.py", line 62, in <module>
    logging.config.dictConfig(dictionary['Logging'])  # Select the logging settings from the dictionary
  File "/usr/lib64/python3.7/logging/config.py", line 799, in dictConfig
    dictConfigClass(config).configure()
  File "/usr/lib64/python3.7/logging/config.py", line 570, in configure
    '%r' % name) from e
ValueError: Unable to configure handler 'radioTelescopeThread'
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/usr/lib64/python3.7/logging/__init__.py", line 2039, in shutdown
    h.close()
  File "/home/radioastronomy/radioTelescopeProgram/pc-gui-app/Core/Handlers/CLogFileHandler.py", line 63, in close
    if self._handler is not None:
AttributeError: 'CustomLogTimedRotationHandler' object has no attribute '_handler'