File: watch.py

package info (click to toggle)
python-fs 0.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,452 kB
  • ctags: 2,991
  • sloc: python: 20,659; makefile: 5
file content (44 lines) | stat: -rw-r--r-- 937 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
"""
fs.osfs.watch
=============

Change watcher support for OSFS

"""

import os
import sys
import errno
import threading

from fs.errors import *
from fs.path import *
from fs.watch import *

OSFSWatchMixin = None

#  Try using native implementation on win32
if sys.platform == "win32":
    try:
        from fs.osfs.watch_win32 import OSFSWatchMixin
    except ImportError:
        pass

#  Try using pyinotify if available
if OSFSWatchMixin is None:
    try:
        from fs.osfs.watch_inotify import OSFSWatchMixin
    except ImportError:
        pass

#  Fall back to raising UnsupportedError
if OSFSWatchMixin is None:
    class OSFSWatchMixin(object):
        def __init__(self, *args, **kwargs):
            super(OSFSWatchMixin, self).__init__(*args, **kwargs)
        def add_watcher(self,*args,**kwds):
            raise UnsupportedError
        def del_watcher(self,watcher_or_callback):
            raise UnsupportedError