# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import with_statement import os import errno import struct import threading import ctypes from functools import reduce from ctypes import c_int, c_char_p, c_uint32 from watchdog.utils import has_attribute, ctypes_find_library libc_string = ctypes_find_library("c", "libc.so") libc = ctypes.CDLL(libc_string, use_errno=True) if ( not has_attribute(libc, "inotify_init") or not has_attribute(libc, "inotify_add_watch") or not has_attribute(libc, "inotify_rm_watch") ): raise ImportError("Unsupported libc version found: %s" % libc_string) inotify_add_watch = ctypes.CFUNCTYPE(c_int, c_int, c_char_p, c_uint32, use_errno=True)(("inotify_add_watch", libc)) inotify_rm_watch = ctypes.CFUNCTYPE(c_int, c_int, c_uint32, use_errno=True)(("inotify_rm_watch", libc)) inotify_init = ctypes.CFUNCTYPE(c_int, use_errno=True)(("inotify_init", libc))
DEFAULT_OBSERVER_TIMEOUT from watchdog.events import\ DirDeletedEvent,\ DirModifiedEvent,\ DirMovedEvent,\ DirCreatedEvent,\ FileDeletedEvent,\ FileModifiedEvent,\ FileMovedEvent,\ FileCreatedEvent,\ EVENT_TYPE_MODIFIED,\ EVENT_TYPE_CREATED,\ EVENT_TYPE_DELETED,\ EVENT_TYPE_MOVED libc_string = ctypes_find_library('c', 'libc.so.6') libc = ctypes.CDLL(libc_string, use_errno=True) if (not has_attribute(libc, 'inotify_init') or not has_attribute(libc, 'inotify_add_watch') or not has_attribute(libc, 'inotify_rm_watch')): raise ImportError("Unsupported libc version found: %s" % libc_string) # #include <sys/inotify.h> # char *strerror(int errnum); #strerror = ctypes.CFUNCTYPE(c_char_p, c_int)( # ("strerror", libc)) # #include <sys/inotify.h> # int inotify_init(void); inotify_init = ctypes.CFUNCTYPE(c_int, use_errno=True)(
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from __future__ import with_statement import os import errno import struct import threading import ctypes from functools import reduce from ctypes import c_int, c_char_p, c_uint32 from watchdog.utils import has_attribute, ctypes_find_library libc_string = ctypes_find_library('c', 'libc.so') libc = ctypes.CDLL(libc_string, use_errno=True) if (not has_attribute(libc, 'inotify_init') or not has_attribute(libc, 'inotify_add_watch') or not has_attribute(libc, 'inotify_rm_watch')): raise ImportError("Unsupported libc version found: %s" % libc_string) inotify_add_watch = ctypes.CFUNCTYPE(c_int, c_int, c_char_p, c_uint32, use_errno=True)( ("inotify_add_watch", libc)) inotify_rm_watch = ctypes.CFUNCTYPE(c_int, c_int, c_uint32,