Skip to main content

Trigger custom commands from filesystem events.

Project description


Trigger custom commands from filesystem events.

Patrol uses libuv, which creates event driven hooks to filesystem events using epoll, kqueue or IOCP.

You can use it to selectively build your project when files change and run tests as soon as you hit the save button.


To install:

sudo pip install patroltrigger

Create a file in your project’s root directory:

from patroltrigger import runnable, run, trigger

@trigger(["*.py", ], exclude=['venv/*',])
def trigger1(filenames):
    print "trigger1"
    run("""echo first command triggered""")
    the_output_is_in_this_variable_though = run("echo this command is run, but the output is not displayed", silent=True)

@trigger(["*.py", ], exclude=['venv/*',])
def trigger2(filenames):
    print "trigger2 command triggered with filename: {}".format(', '.join(filenames))
    run("false", ignore_errors=True)    # If ignore_errors=False, nothing further will be executed.
    run("""echo if ignore_errors is False or not specified, you wont ever see this command *or* the results of trigger3.""")

@trigger(["*.py", ], exclude=['venv/*',])
def trigger3(filenames):
    print "trigger3 command triggered with filename: {}".format(', '.join(filenames))


Run like so:

$ python

Or get help:

$ python --help
Usage: [options]

-h, --help            show this help message and exit
-r RUN, --run=RUN     Specify a method in to run directly.
-a, --all             Run all methods in in priority order.
-p POST, --post=POST  Command to run after a trigger (e.g. guake)
                        Directory to run in (default:


  • If multiple methods are triggered by a changed file, they will run in the order they appear in

  • Queue up triggers by putting a file named ‘lock’ in the directory is run from. Once ‘lock’ is removed, the pent up triggers will all be fired.

  • Each time a set of methods are triggered, the total run time is timed.

  • If a command fails (e.g. a unit test), the method is aborted by default at that point to shorten feedback time. Subsequent methods will not run.

  • Run a custom command after each method is finished (e.g. guake, notify-send).

  • Ability to run commands manually.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

patroltrigger-0.3.tar.gz (5.2 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page