From ac54ee2ece169f46ee995b84784d64098edd5e16 Mon Sep 17 00:00:00 2001 From: nmccouat Date: Wed, 16 Feb 2022 13:21:50 +0900 Subject: [PATCH] fix attributeerror when non-blocking open not supported on windows fixes https://github.com/derpston/python-multitail2/issues/12 --- src/multitail2.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/multitail2.py b/src/multitail2.py index a0a941a..4605bf9 100644 --- a/src/multitail2.py +++ b/src/multitail2.py @@ -4,6 +4,9 @@ import os import random import six +import sys + +is_windows = sys.platform == 'win32' __version__ = "1.5.2" logger = logging.getLogger(__name__) @@ -27,7 +30,8 @@ def _close(self): def _open(self, path, skip_to_end = True, offset = None): """Open `path`, optionally seeking to the end if `skip_to_end` is True.""" - fh = os.fdopen(os.open(path, os.O_RDONLY | os.O_NONBLOCK)) + flags = os.O_RDONLY if is_windows else (os.O_RDONLY | os.O_NONBLOCK) + fh = os.fdopen(os.open(path, flags)) # If the file is being opened for the first time, jump to the end. # Otherwise, it is being reopened after a rotation, and we want