Skip to main content

Call a command when a directory changes. (Mac OS only)

Project description

icemac.callonchange calls a specific command when a directory or something in it has changed. It was developed to ease test driven development (TDD): it can call the test case under development each time the test case or the developed code changes.

Requirements

  • Mac OS X 10.5+ (Leopard)

  • Python 2.5

General usage

Usage: callonchange [options] path utility [utility arguments]

callonchange invokes utility with its utility arguments when path or something in it changes.

Options:
--version

show program’s version number and exit

-h, --help

show this help message and exit

-e EXTENSION

only call utility on changes of a file with this extension (option might be used multiple times)

-q

Do not display any output of callonchange. (Still displays the output of the utility.)

EXTENSION might be specified with or without a leading dot:

-e .py is equal to -e py is equal to -epy

Caution: optional arguments must be specified before the positional arguments (path and utility). Arguments specified after the positional arguments are taken as arguments of the utility.

Usage as script

Installation

To install callonchange as script call:

$ python setup.py install

or install it using a package manager like easy_install or pip.

Call as script

To call it as a script add the path to the directory to be observed and the command (script or program) to be called when the directory or something in it has changed.

Example to call xeyes when a file with the extension log has changed in /var/log enter:

$ callonchange -e log /var/log xeyes

Caution: In this example xeyes is called on every new entry in the log file.

In buildout

There is a recipe in the package which eases installation using buildout.

Installation with default arguments

Add a section to your buildout to generate a script for callonchange (don’t forget to add it to the parts!):

[coc]
recipe = icemac.callonchange

This creates a callonchange script with default arguments. These are:

'-e', 'py', '-e', 'zcml', '-e', 'pt', '-e', 'txt', 'src', 'bin/test', '-cv'

Which means: observe in the src directory files with the extensions py, zcml, pt and txt. Call bin/test with the arguments cv (verbose and color) on changes.

Installation with customized arguments

To override the default arguments add an arguments parameter to the buildout section:

[coc]
recipe = icemac.callonchange
name = coc
arguments = 'Products', 'bin/ztest'

This means: The created script will be named coc. When called it will observe the Products directory and call bin/ztest on changes.

Usage as buildout script

You can add additional parameters when you call the generated script:

$ bin/callonchange -t testObserver

When you use the default arguments in the buildout section, this command line calls bin/test -cv -t testObserver on each change of py, zcml, pt or txt files in the src directory.

Stopping callonchange

To stop a running callonchange instance hit ^C (Control-C).

Runing the tests

To run the tests of icemac.callonchange call:

$ python setup.py test

or use buildout:

$ python bootstrap.py
$ bin/buildout
$ bin/test

or use callonchange itself:

$ python bootstrap.py
$ bin/buildout
$ bin/callonchange

In the last version you have to change something inside the src directory of the package so the observer lets the tests run.

Thanks

Thanks to Malte Borch for the great MacFSEvents which icemac.callonchange is based on.

Similar tools

  • pest: “Auto tester for python” Seems to be designed to run tests and nothing else. Has growl integration. Current version (1.0.3) has no automatic tests.

  • sniffer: “An automatic test runner. Supports nose out of the box.” Supports Linux, Windows and Mac OS X. But in current version (0.1.3) Windows and Mac OS X are untested. Current version has no automatic tests.

  • autonose: “continuous test tracker / runner for nosetests” Seems to focus on nose tests. Version 0.1.3 only acts on changes of python files. Detects file changes not using file system events. So it is slow on lager code bases.

Ideas

  • It would be nice to have predefined argument lines (profiles) even when not using buildout. They could be stored in the home directory of the user. (Should support profiles which reverence other profiles.)

  • In buildout recipe: default script name should be section name.

  • A minimal time between calls might be nice, so a change does not result in a call when it occurred during this time.

  • The options of callonchange should have long variants, too.

  • Compatibility with Python versions beside 2.5 would be nice.

Changelog

0.5 (2010-07-21)

  • Added –version option to callonchange.

  • Added another similar tool to the list.

0.4 (2010-07-16)

  • When the utility gets called a messge is displayed. This can be omitted by specifying the -q option for callonchange.

  • When the utility is not found or another OSError occurred when calling the utility callonchange is now stopped.

0.3.2 (2010-07-14)

  • Added list of similar tools.

0.3.1 (2010-07-10)

  • Fixed incorrect handling of the find-links buildout parameter.

0.3 (2010-07-07)

  • Added abbility to specify file extensions so only files with these extensions will be observed.

  • Added a name parameter to the recipe to control the name of the generated script, e. g. allowing more than one icemac.callonchange script in a buildout.

0.2 (2010-07-04)

  • Added buildout recipe to ease integration with buildout projects. (See section In buildout.)

0.1 (2010-07-02)

  • Initial release.

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

icemac.callonchange-0.5.tar.gz (13.3 kB view details)

Uploaded Source

File details

Details for the file icemac.callonchange-0.5.tar.gz.

File metadata

File hashes

Hashes for icemac.callonchange-0.5.tar.gz
Algorithm Hash digest
SHA256 87817c2a9a740d0c4dad19e4697fc7b1dd36176532739cd2ffd97151aa2fdc49
MD5 a950800350fd64ef465893bfd6398cc5
BLAKE2b-256 35c825cd36a65c73364ce55b21b84b359847b759f8a1890d5cf3c9a16e35cab5

See more details on using hashes here.

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