diff --git a/adafruit_logging.py b/adafruit_logging.py index 301dabc..29ff855 100644 --- a/adafruit_logging.py +++ b/adafruit_logging.py @@ -55,6 +55,7 @@ """ +import errno import os import sys import time @@ -387,7 +388,7 @@ def doRollover(self) -> None: # Rename the current file to the next number in the sequence. os.rename(CurrentFileName, CurrentFileNamePlus) except OSError as e: - if e.args[0] == 2: + if e.errno == errno.ENOENT: # File does not exsist. This is okay. pass else: @@ -405,7 +406,7 @@ def GetLogSize(self) -> int | None: self.stream.flush() # We need to call this or the file size is always zero. LogFileSize = os.stat(self._LogFileName)[6] except OSError as e: - if e.args[0] == 2: + if e.errno == errno.ENOENT: # Log file does not exsist. This is okay. LogFileSize = None else: