~ubuntu-branches/ubuntu/wily/python-watchdog/wily

« back to all changes in this revision

Viewing changes to src/watchdog/observers/read_directory_changes_async.py

  • Committer: Package Import Robot
  • Author(s): gustavo panizzo
  • Date: 2014-01-26 10:29:40 UTC
  • Revision ID: package-import@ubuntu.com-20140126102940-601093u3h1hp35b2
Tags: upstream-0.7.0
ImportĀ upstreamĀ versionĀ 0.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# -*- coding: utf-8 -*-
 
3
#
 
4
# Copyright 2011 Yesudeep Mangalapilly <yesudeep@gmail.com>
 
5
# Copyright 2012 Google, Inc.
 
6
#
 
7
# Licensed under the Apache License, Version 2.0 (the "License");
 
8
# you may not use this file except in compliance with the License.
 
9
# You may obtain a copy of the License at
 
10
#
 
11
#     http://www.apache.org/licenses/LICENSE-2.0
 
12
#
 
13
# Unless required by applicable law or agreed to in writing, software
 
14
# distributed under the License is distributed on an "AS IS" BASIS,
 
15
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
# See the License for the specific language governing permissions and
 
17
# limitations under the License.
 
18
 
 
19
 
 
20
from __future__ import with_statement
 
21
 
 
22
raise ImportError("Not implemented yet.")
 
23
 
 
24
from watchdog.utils import platform
 
25
 
 
26
if platform.is_windows():
 
27
    import threading
 
28
 
 
29
    from watchdog.observers.api import (
 
30
        EventEmitter,
 
31
        BaseObserver,
 
32
        DEFAULT_OBSERVER_TIMEOUT,
 
33
        DEFAULT_EMITTER_TIMEOUT
 
34
    )
 
35
 
 
36
    class WindowsApiAsyncEmitter(EventEmitter):
 
37
 
 
38
        """
 
39
        Platform-independent emitter that polls a directory to detect file
 
40
        system changes.
 
41
        """
 
42
 
 
43
        def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
 
44
            EventEmitter.__init__(self, event_queue, watch, timeout)
 
45
            self._lock = threading.Lock()
 
46
 
 
47
        def queue_events(self, timeout):
 
48
            with self._lock:
 
49
                pass
 
50
 
 
51
    class WindowsApiAsyncObserver(BaseObserver):
 
52
 
 
53
        """
 
54
        Observer thread that schedules watching directories and dispatches
 
55
        calls to event handlers.
 
56
        """
 
57
 
 
58
        def __init__(self, timeout=DEFAULT_OBSERVER_TIMEOUT):
 
59
            BaseObserver.__init__(self, emitter_class=WindowsApiAsyncEmitter,
 
60
                                  timeout=timeout)