Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2009-2012, Peter Bengtsson and contributors.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of Peter Bengtsson nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include README.rst requirements.txt LICENSE
81 changes: 45 additions & 36 deletions README.md → README.rst
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#####
gorun
=====
#####

(c) Peter Bengtsson, Fry-IT, peter@fry-it.com, 2009-2010
License: Python


Using (py)inotify to run commands when files change
---------------------------------------------------
===================================================

Tired of switching console, arrow-up, Enter, switch console back for
every little change you make when you're writing code that has tests?
Running with `gorun.py` enables you to just save in your editor and
Running with ``gorun.py`` enables you to just save in your editor and
the tests are run automatically and immediately.

`gorun.py` does not use a slow pulling process which keeps taps on
files modification time. Instead it uses the
[inotify](http://en.wikipedia.org/wiki/Inotify) which is...
``gorun.py`` does not use a slow pulling process which keeps taps on
files modification time. Instead it uses the inotify_ which is "a Linux kernel
subsystem that provides file system event notification".

> inotify is a Linux kernel subsystem that provides file system event
> notification
.. _inotify: http://en.wikipedia.org/wiki/Inotify


Installation
Expand All @@ -27,28 +27,33 @@ Installation
This will only work on Linux which has the inotify module enabled in
the kernel. (Most modern kernels do)

First install [pyinotify](http://trac.dbzteam.org/pyinotify) the usual
way:

$ easy_install pyinotify

Then download `gorun` and put `gorun.py` into your `~/bin` directory
and make it executable. Then, create a settings file, which is just a
python file that is expected to define a variable called
`DIRECTORIES`. Here's an example:

DIRECTORIES = (
('some/place/', './myframework test --dir some/place'),
('some/place/unitests.py',
'./myframework test --dir some/place --testclass Unittests'),
('/var/log/torrentsdownload.log',
'growl downloads --logfile /var/log/torrentsdownload.log'),
)

Save that file as, for example, `gorun_settings.py` and then start it
::

pip install gorun

This will install pyinotify_.

.. _pyinotify: http://trac.dbzteam.org/pyinotify

Then, create a settings file, which is just a python file that is expected to
define a variable called ``DIRECTORIES``. Here's an example:

::

DIRECTORIES = (
('some/place/', './myframework test --dir some/place'),
('some/place/unitests.py',
'./myframework test --dir some/place --testclass Unittests'),
('/var/log/torrentsdownload.log',
'growl downloads --logfile /var/log/torrentsdownload.log'),
)

Save that file as, for example, ``gorun_settings.py`` and then start it
like this:

$ gorun.py gorun_settings
::

$ gorun.py gorun_settings

Configuration
-------------
Expand All @@ -59,16 +64,20 @@ files from certain editors are automatically created (e.g. #foo.py# or
foo.py~) and these are ignored. If there are other file extensions you
want gorun to ignore add this to your settings file:

IGNORE_EXTENSIONS = ('log',)

::

IGNORE_EXTENSIONS = ('log',)

This will add to the list of already ignored file extensions such as
`.pyc`.
``.pyc``.

Similarly, if there are certain directories that you don't want the
inotify to notice, you can list them like this:

IGNORE_DIRECTORIES = ('xapian_index', '.autosavefiles')

::

IGNORE_DIRECTORIES = ('xapian_index', '.autosavefiles')

Disclaimer
----------

Expand All @@ -82,8 +91,8 @@ Todo
When doing Django development I often run on single test method over
and over and over again till I get rid of all errors. When doing this
I have to change the settings so it just runs one single test and when
I'm done I go back to set it up so that it runs all tests when adjacent
code works.
I'm done I go back to set it up so that it runs all tests when adjacent
code works.

This is a nuisance and I might try to solve that one day. If you have
any tips please let me know.
any tips please let me know.
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pyinotify==0.9.3
48 changes: 31 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
#!/usr/bin/env python

import os
import setuptools # for zip_safe and install_requires
from distutils.core import setup

def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()

setup(name = 'python-gorun',
version = '1.6',
description = 'Wrapper on pyinotify for running commands (often tests)',
long_description = read('README.md'),
author='Peter Bengtsson',
author_email='peter@fry-it.com',
url = 'http://github.com/peterbe/python-gorun',
classifiers = [
'Programming Language :: Python :: 2',
'Intended Audience :: Developers',
'Operating System :: POSIX :: Linux',
'Topic :: Software Development :: Testing'
'Topic :: Software Development :: Build Tools'
],
scripts = ['gorun.py']
with open('README.rst') as readme:
long_description = readme.read()


with open('requirements.txt') as reqs:
install_requires = [
line for line in reqs.read().split('\n') if (line and not
line.startswith('--'))
]


setup(
name='gorun',
version='1.6',
description='Wrapper on pyinotify for running commands (often tests)',
long_description=long_description,
author='Peter Bengtsson',
author_email='peter@fry-it.com',
url='http://github.com/peterbe/python-gorun',
license='BSD',
classifiers=[
'Programming Language :: Python :: 2',
'Intended Audience :: Developers',
'Operating System :: POSIX :: Linux',
'Topic :: Software Development :: Testing',
'Topic :: Software Development :: Build Tools',
],
scripts=['gorun.py'],
zip_safe=False,
install_requires=install_requires,
)