<?xml version="1.0" ?>
<?xml-stylesheet type='text/xsl' href='interface.xsl'?>
<interface uri="http://gfxmonk.net/dist/0install/watchdog.xml" xmlns="http://zero-install.sourceforge.net/2004/injector/interface">
	<name>watchdog</name>
	<summary>Cross-platform filesystem monitoring for python</summary>
	<description>
Watchdog
========
Python API and shell utilities to monitor file system events.


Example API Usage
-----------------
A simple program that uses watchdog to monitor directories specified
as command-line arguments and logs events generated::

    import sys
    import time
    import logging
    from watchdog.observers import Observer
    from watchdog.events import LoggingEventHandler

    if __name__ == &quot;__main__&quot;:
        logging.basicConfig(level=logging.INFO,
                            format='%(asctime)s - %(message)s',
                            datefmt='%Y-%m-%d %H:%M:%S')
        event_handler = LoggingEventHandler()
        observer = Observer()
        observer.schedule(event_handler, path=sys.argv[1], recursive=True)
        observer.start()
        try:
            while True:
                time.sleep(1)
        except KeyboardInterrupt:
            observer.stop()
        observer.join()


Shell Utilities
---------------
Watchdog comes with a utility script called ``watchmedo``.
Please type ``watchmedo --help`` at the shell prompt to
know more about this tool.

Here is how you can log the current directory recursively
for events related only to ``*.py`` and ``*.txt`` files while
ignoring all directory events::

    watchmedo log \
        --patterns=&quot;*.py;*.txt&quot; \
        --ignore-directories \
        --recursive \
        .

You can use the ``shell-command`` subcommand to execute shell commands in
response to events::

    watchmedo shell-command \
        --patterns=&quot;*.py;*.txt&quot; \
        --recursive \
        --command='echo &quot;${watch_src_path}&quot;' \
        .

Please see the help information for these commands by typing::

    watchmedo [command] --help


About ``watchmedo`` Tricks
~~~~~~~~~~~~~~~~~~~~~~~~~~
``watchmedo`` can read ``tricks.yaml`` files and execute tricks within them in
response to file system events. Tricks are actually event handlers that
subclass ``watchdog.tricks.Trick`` and are written by plugin authors. Trick
classes are augmented with a few additional features that regular event handlers
don't need.

An example ``tricks.yaml`` file::

    tricks:
    - watchdog.tricks.LoggerTrick:
        patterns: [&quot;*.py&quot;, &quot;*.js&quot;]
    - watchmedo_webtricks.GoogleClosureTrick:
        patterns: ['*.js']
        hash_names: true
        mappings_format: json                  # json|yaml|python
        mappings_module: app/javascript_mappings
        suffix: .min.js
        compilation_level: advanced            # simple|advanced
        source_directory: app/static/js/
        destination_directory: app/public/js/
        files:
          index-page:
          - app/static/js/vendor/jquery*.js
          - app/static/js/base.js
          - app/static/js/index-page.js
          about-page:
          - app/static/js/vendor/jquery*.js
          - app/static/js/base.js
          - app/static/js/about-page/**/*.js

The directory containing the ``tricks.yaml`` file will be monitored. Each trick
class is initialized with its corresponding keys in the ``tricks.yaml`` file as
arguments and events are fed to an instance of this class as they arrive.

Tricks will be included in the 0.5.0 release. I need community input about them.
Please file enhancement requests at the `issue tracker`_.


Installation
------------
Installing from PyPI using ``pip``::

    pip install watchdog

Installing from PyPI using ``easy_install``::

    easy_install watchdog

Installing from source::

    python setup.py install


Installation Caveats
~~~~~~~~~~~~~~~~~~~~
The ``watchmedo`` script depends on PyYAML_ which links with LibYAML_,
which brings a performance boost to the PyYAML parser. However, installing
LibYAML_ is optional but recommended. On Mac OS X, you can use homebrew_
to install LibYAML::

    brew install libyaml

On Linux, use your favorite package manager to install LibYAML. Here's how you
do it on Ubuntu::

    sudo aptitude install libyaml-dev

On Windows, please install PyYAML_ using the binaries they provide.

Documentation
-------------
You can browse the latest release documentation_ online.

Supported Platforms
-------------------
* Linux 2.6 (inotify)
* Mac OS X (FSEvents, kqueue)
* FreeBSD/BSD (kqueue)
* Windows (ReadDirectoryChangesW with I/O completion ports;
  ReadDirectoryChangesW worker threads)
* OS-independent (polling the disk for directory snapshots and comparing them
  periodically; slow and not recommended)

Note that when using watchdog with kqueue, you need the 
number of file descriptors allowed to be opened by programs
running on your system to be increased to more than the 
number of files that you will be monitoring. The easiest way
to do that is to edit your ``~/.profile`` file and add
a line similar to::

    ulimit -n 1024

This is an inherent problem with kqueue because it uses
file descriptors to monitor files. That plus the enormous
amount of bookkeeping that watchdog needs to do in order
to monitor file descriptors just makes this a painful way
to monitor files and directories. In essence, kqueue is
not a very scalable way to monitor a deeply nested 
directory of files and directories with a large number of
files.

About using watchdog with editors like Vim
------------------------------------------
Vim does not modify files unless directed to do so.
It creates backup files and then swaps it in to replace
the file you are editing on the disk. This means that
if you use Vim to edit your files, the on-modified events
for those files will not be triggered by watchdog.
You may need to configure Vim to avoid using swapfiles::

    set noswapfile

in your ``~/.vimrc`` should deal with this situation.


Dependencies
------------
1. Python 2.5 or above.
2. XCode_ (only on Mac OS X)
3. PyYAML_
4. argh_
5. select_backport_ (select.kqueue replacement for Python2.5/2.6 on BSD/Mac OS X)
6. pathtools_


Licensing
---------
Watchdog is licensed under the terms of the `Apache License, version 2.0`_.

Copyright (C) 2011 `Yesudeep Mangalapilly`_ and the Watchdog authors.

Project `source code`_ is available at Github. Please report bugs and file
enhancement requests at the `issue tracker`_.

Why Watchdog?
-------------
Too many people tried to do the same thing and none did what I needed Python
to do:

* pnotify_
* `unison fsmonitor`_
* fsmonitor_
* guard_
* pyinotify_
* `inotify-tools`_
* jnotify_
* treewalker_
* `file.monitor`_
* pyfilesystem_

.. links:
.. _Yesudeep Mangalapilly: yesudeep@gmail.com
.. _source code: http://github.com/gorakhargosh/watchdog
.. _issue tracker: http://github.com/gorakhargosh/watchdog/issues
.. _Apache License, version 2.0: http://www.apache.org/licenses/LICENSE-2.0
.. _documentation: http://packages.python.org/watchdog/

.. _homebrew: http://mxcl.github.com/homebrew/
.. _select_backport: http://pypi.python.org/pypi/select_backport
.. _argh: http://pypi.python.org/pypi/argh
.. _PyYAML: http://www.pyyaml.org/
.. _XCode: http://developer.apple.com/technologies/tools/xcode.html
.. _LibYAML: http://pyyaml.org/wiki/LibYAML
.. _pathtools: http://github.com/gorakhargosh/pathtools

.. _pnotify: http://mark.heily.com/pnotify
.. _unison fsmonitor: https://webdav.seas.upenn.edu/viewvc/unison/trunk/src/fsmonitor.py?view=markup&amp;pathrev=471
.. _fsmonitor: http://github.com/shaurz/fsmonitor
.. _guard: http://github.com/guard/guard
.. _pyinotify: http://github.com/seb-m/pyinotify
.. _inotify-tools: http://github.com/rvoicilas/inotify-tools
.. _jnotify: http://jnotify.sourceforge.net/
.. _treewalker: http://github.com/jbd/treewatcher
.. _file.monitor: http://github.com/pke/file.monitor
.. _pyfilesystem: http://code.google.com/p/pyfilesystem

	</description>
	<homepage>https://github.com/gorakhargosh/watchdog</homepage>
	<publish mode="third-party" xmlns="http://gfxmonk.net/dist/0install"/>
	<rich-description xmlns="http://gfxmonk.net/dist/0install">
		<div xmlns="http://www.w3.org/1999/xhtml">
			<h1 id="watchdog">Watchdog</h1>
			<p>Python API and shell utilities to monitor file system events.</p>
			<h2 id="example-api-usage">Example API Usage</h2>
			<p>A simple program that uses watchdog to monitor directories specified as command-line arguments and logs events generated:</p>
			<pre><code>import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler

if __name__ == &quot;__main__&quot;:
    logging.basicConfig(level=logging.INFO,
                        format='%(asctime)s - %(message)s',
                        datefmt='%Y-%m-%d %H:%M:%S')
    event_handler = LoggingEventHandler()
    observer = Observer()
    observer.schedule(event_handler, path=sys.argv[1], recursive=True)
    observer.start()
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()
</code></pre>
			<h2 id="shell-utilities">Shell Utilities</h2>
			<p>Watchdog comes with a utility script called <code>watchmedo</code>. Please type <code>watchmedo --help</code> at the shell prompt to know more about this tool.</p>
			<p>Here is how you can log the current directory recursively for events related only to <code>*.py</code> and <code>*.txt</code> files while ignoring all directory events:</p>
			<pre><code>watchmedo log \
    --patterns=&quot;*.py;*.txt&quot; \
    --ignore-directories \
    --recursive \
    .
</code></pre>
			<p>You can use the <code>shell-command</code> subcommand to execute shell commands in response to events:</p>
			<pre><code>watchmedo shell-command \
    --patterns=&quot;*.py;*.txt&quot; \
    --recursive \
    --command='echo &quot;${watch_src_path}&quot;' \
    .
</code></pre>
			<p>Please see the help information for these commands by typing:</p>
			<pre><code>watchmedo [command] --help
</code></pre>
			<h3 id="about-watchmedo-tricks">About <code>watchmedo</code> Tricks</h3>
			<p><code>watchmedo</code> can read <code>tricks.yaml</code> files and execute tricks within them in response to file system events. Tricks are actually event handlers that subclass <code>watchdog.tricks.Trick</code> and are written by plugin authors. Trick classes are augmented with a few additional features that regular event handlers don't need.</p>
			<p>An example <code>tricks.yaml</code> <a href="file::">file::</a></p>
			<blockquote>
				<p>tricks: - watchdog.tricks.LoggerTrick: patterns: [&quot;<em>.py&quot;, &quot;</em>.js&quot;] - watchmedo_webtricks.GoogleClosureTrick: patterns: ['<em>.js'] hash_names: true mappings_format: json # json|yaml|python mappings_module: app/javascript_mappings suffix: .min.js compilation_level: advanced # simple|advanced source_directory: app/static/js/ destination_directory: app/public/js/ files: index-page: - app/static/js/vendor/jquery</em>.js - app/static/js/base.js - app/static/js/index-page.js about-page: - app/static/js/vendor/jquery<em>.js - app/static/js/base.js - app/static/js/about-page/</em><em>/</em>.js</p>
			</blockquote>
			<p>The directory containing the <code>tricks.yaml</code> file will be monitored. Each trick class is initialized with its corresponding keys in the <code>tricks.yaml</code> file as arguments and events are fed to an instance of this class as they arrive.</p>
			<p>Tricks will be included in the 0.5.0 release. I need community input about them. Please file enhancement requests at the `issue tracker`_.</p>
			<h2 id="installation">Installation</h2>
			<p>Installing from PyPI using <code>pip</code>:</p>
			<pre><code>pip install watchdog
</code></pre>
			<p>Installing from PyPI using <code>easy_install</code>:</p>
			<pre><code>easy_install watchdog
</code></pre>
			<p>Installing from source:</p>
			<pre><code>python setup.py install
</code></pre>
			<h3 id="installation-caveats">Installation Caveats</h3>
			<p>The <code>watchmedo</code> script depends on <a href="http://www.pyyaml.org/">PyYAML</a> which links with <a href="http://pyyaml.org/wiki/LibYAML">LibYAML</a>, which brings a performance boost to the PyYAML parser. However, installing <a href="http://pyyaml.org/wiki/LibYAML">LibYAML</a> is optional but recommended. On Mac OS X, you can use <a href="http://mxcl.github.com/homebrew/">homebrew</a> to install LibYAML:</p>
			<pre><code>brew install libyaml
</code></pre>
			<p>On Linux, use your favorite package manager to install LibYAML. Here's how you do it on Ubuntu:</p>
			<pre><code>sudo aptitude install libyaml-dev
</code></pre>
			<p>On Windows, please install <a href="http://www.pyyaml.org/">PyYAML</a> using the binaries they provide.</p>
			<h2 id="documentation">Documentation</h2>
			<p>You can browse the latest release documentation_ online.</p>
			<h2 id="supported-platforms">Supported Platforms</h2>
			<ul>
				<li>Linux 2.6 (inotify)</li>
				<li>Mac OS X (FSEvents, kqueue)</li>
				<li>FreeBSD/BSD (kqueue)</li>
				<li>Windows (ReadDirectoryChangesW with I/O completion ports; ReadDirectoryChangesW worker threads)</li>
				<li>OS-independent (polling the disk for directory snapshots and comparing them periodically; slow and not recommended)</li>
			</ul>
			<p>Note that when using watchdog with kqueue, you need the number of file descriptors allowed to be opened by programs running on your system to be increased to more than the number of files that you will be monitoring. The easiest way to do that is to edit your <code>~/.profile</code> file and add a line similar to:</p>
			<pre><code>ulimit -n 1024
</code></pre>
			<p>This is an inherent problem with kqueue because it uses file descriptors to monitor files. That plus the enormous amount of bookkeeping that watchdog needs to do in order to monitor file descriptors just makes this a painful way to monitor files and directories. In essence, kqueue is not a very scalable way to monitor a deeply nested directory of files and directories with a large number of files.</p>
			<h2 id="about-using-watchdog-with-editors-like-vim">About using watchdog with editors like Vim</h2>
			<p>Vim does not modify files unless directed to do so. It creates backup files and then swaps it in to replace the file you are editing on the disk. This means that if you use Vim to edit your files, the on-modified events for those files will not be triggered by watchdog. You may need to configure Vim to avoid using swapfiles:</p>
			<pre><code>set noswapfile
</code></pre>
			<p>in your <code>~/.vimrc</code> should deal with this situation.</p>
			<h2 id="dependencies">Dependencies</h2>
			<ol style="list-style-type: decimal">
				<li>Python 2.5 or above.</li>
				<li><a href="http://developer.apple.com/technologies/tools/xcode.html">XCode</a> (only on Mac OS X)</li>
				<li>
					<a href="http://www.pyyaml.org/">PyYAML</a>
				</li>
				<li>
					<a href="http://pypi.python.org/pypi/argh">argh</a>
				</li>
				<li><a href="http://pypi.python.org/pypi/select_backport">select_backport</a> (select.kqueue replacement for Python2.5/2.6 on BSD/Mac OS X)</li>
				<li>
					<a href="http://github.com/gorakhargosh/pathtools">pathtools</a>
				</li>
			</ol>
			<h2 id="licensing">Licensing</h2>
			<p>Watchdog is licensed under the terms of the `Apache License, version 2.0`_.</p>
			<p>Copyright (C) 2011 `Yesudeep Mangalapilly`_ and the Watchdog authors.</p>
			<p>Project `source code`_ is available at Github. Please report bugs and file enhancement requests at the `issue tracker`_.</p>
			<h2 id="why-watchdog">Why Watchdog?</h2>
			<p>Too many people tried to do the same thing and none did what I needed Python to do:</p>
			<ul>
				<li>
					<a href="http://mark.heily.com/pnotify">pnotify</a>
				</li>
				<li>
					<a href="https://webdav.seas.upenn.edu/viewvc/unison/trunk/src/fsmonitor.py?view=markup&amp;pathrev=471">unison fsmonitor</a>
				</li>
				<li>
					<a href="http://github.com/shaurz/fsmonitor">fsmonitor</a>
				</li>
				<li>
					<a href="http://github.com/guard/guard">guard</a>
				</li>
				<li>
					<a href="http://github.com/seb-m/pyinotify">pyinotify</a>
				</li>
				<li>`inotify-tools`_</li>
				<li>
					<a href="http://jnotify.sourceforge.net/">jnotify</a>
				</li>
				<li>
					<a href="http://github.com/jbd/treewatcher">treewalker</a>
				</li>
				<li>`file.monitor`_</li>
				<li>
					<a href="http://code.google.com/p/pyfilesystem">pyfilesystem</a>
				</li>
			</ul>
		</div>
	</rich-description>
	<group main="watchdog/watchmedo.py">
		<command name="test">
			<runner interface="http://gfxmonk.net/dist/0install/nosetests-runner.xml"/>
			<arg>-v</arg>
		</command>
		<environment insert="" mode="prepend" name="PYTHONPATH"/>
		<requires interface="http://gfxmonk.net/dist/0install/pyyaml-python2.xml">
			<version not-before="3.09"/>
		</requires>
		<requires interface="http://gfxmonk.net/dist/0install/argh.xml">
			<version not-before="0.8.1"/>
		</requires>
		<requires interface="http://gfxmonk.net/dist/0install/argparse.xml">
			<version not-before="1.1"/>
		</requires>
		<requires interface="http://gfxmonk.net/dist/0install/pathtools.xml">
			<version not-before="0.1.1"/>
		</requires>
		<requires interface="http://gfxmonk.net/dist/0install/python-brownie.xml"/>
		<implementation id="sha1new=32616e915c5ee25d835ed38421f15ebbe84b438f" released="2011-01-22" version="0.5.0">
			<manifest-digest sha256="bf9ad7466721c836fa01c99843f1260b0cee7e022b1ec02fcc1ce6ca83ad1d60"/>
			<archive href="http://gfxmonk.net/dist/0install/watchdog/watchdog-0.5.0.tgz" size="83809"/>
		</implementation>
		<implementation id="sha1new=fade22cc91513107a7b429688ccfc179c880114d" released="2011-02-02" version="0.5.1">
			<manifest-digest sha256="c8f3e4c76381fca235078a7a35d8271fb7db94ac940d7659e5ef2fd00b751a0b"/>
			<archive href="http://gfxmonk.net/dist/0install/watchdog/watchdog-0.5.1.tgz" size="83881"/>
		</implementation>
		<implementation id="sha1new=b6d40c5d38b58c1be359d879dadc90d212f9294c" released="2011-02-09" version="0.5.3">
			<manifest-digest sha256="c1fa271909f9bb2754927a7ef07b37f5dad01a3a179d90a532f5a791e2ec3fc9"/>
			<archive href="http://gfxmonk.net/dist/0install/watchdog/watchdog-0.5.3.tgz" size="83971"/>
		</implementation>
	</group>
	<group main="src/watchdog/watchmedo.py">
		<command name="test">
			<runner interface="http://gfxmonk.net/dist/0install/nosetests-runner.xml"/>
			<arg>-v</arg>
		</command>
		<environment insert="src" mode="prepend" name="PYTHONPATH"/>
		<requires interface="http://gfxmonk.net/dist/0install/python-brownie.xml"/>
		<requires interface="http://gfxmonk.net/dist/0install/pyyaml-python2.xml">
			<version not-before="3.09"/>
		</requires>
		<requires interface="http://gfxmonk.net/dist/0install/argh.xml">
			<version not-before="0.8.1"/>
		</requires>
		<requires interface="http://gfxmonk.net/dist/0install/argparse.xml">
			<version not-before="1.1"/>
		</requires>
		<requires interface="http://gfxmonk.net/dist/0install/pathtools.xml">
			<version not-before="0.1.1"/>
		</requires>
		<implementation id="sha1new=a0caf3d2356f0b685ca1a8ac0ffbdffc7d0f9889" main="src/watchdog/watchmedo.py" released="2011-08-30" version="0.5.4">
			<archive extract="gorakhargosh-watchdog-765ed49" href="https://github.com/gorakhargosh/watchdog/tarball/v0.5.4" size="72583" type="application/x-compressed-tar"/>
		</implementation>
	</group>
	<group main="src/watchdog/watchmedo.py">
		<command name="test">
			<requires interface="http://gfxmonk.net/dist/0install/python-unittest2.xml"/>
			<runner interface="http://gfxmonk.net/dist/0install/nosetests-runner.xml"/>
			<arg>-v</arg>
		</command>
		<requires interface="http://repo.roscidus.com/python/python">
			<version before="3.0"/>
		</requires>
		<command name="run" path="src/watchdog/watchmedo.py">
			<runner interface="http://repo.roscidus.com/python/python"/>
			<requires interface="http://gfxmonk.net/dist/0install/pyyaml-python2.xml">
				<version not-before="3.09"/>
			</requires>
			<requires interface="http://gfxmonk.net/dist/0install/argh.xml">
				<version not-before="0.8.1"/>
			</requires>
		</command>
		<environment insert="src" mode="prepend" name="PYTHONPATH"/>
		<requires interface="http://gfxmonk.net/dist/0install/pathtools.xml">
			<version not-before="0.1.1"/>
		</requires>
		<implementation id="sha1new=294f644f7de4fa2fe862487a206a8613ca897068" released="2012-01-26" version="0.5.4-post-20120126">
			<manifest-digest sha256="f329ad1a6383f738632fba1e4552e6252ebe979cf755713b266c4b66ce791b81"/>
			<archive href="http://gfxmonk.net/dist/0install/watchdog/watchdog-0.5.4-post-20120126.tgz" size="101835"/>
		</implementation>
	</group>
</interface>
<!-- Base64 Signature
iEYEABECAAYFAk+MA5IACgkQ/lhgK1iJTtI8egCgveUBBtEHEm7USrM9Mk8eL8Ke9VkAnRPEk1Mg
37+tyYsAtlDqr9JZc703

-->

