On Wed, Apr 27, 2011 at 5:10 PM, Shawn Milochik <[email protected]> wrote:

> Core devs,
>
> I've written a script which monitors my project path for changes with
> pyinotify [1] and automatically runs my test suite each time I save a
> Python file.
>
> I was doing this by calling subprocess, but someone helpfully pointed
> me towards call_command[2]. However, this breaks my script, which is
> using a loop that's baked into pyinotify's Notifier class.
>
> The problem is that the handler function [3] calls sys.exit() if there
> are any test failures. Given that the function is already done at this
> point, it seems redundant.
>
> I can just as easily go back to using subprocess, but it seems silly
> to shell out of Python to call a Python function. Is there any reason
> not to change this sys.exit() to a sys.stderr.write()?
>
> Thanks for your time.
>
> Shawn
>
> [1] https://github.com/seb-m/pyinotify
> [2]
> http://docs.djangoproject.com/en/dev/ref/django-admin/#running-management-commands-from-your-code
> [3]
> http://code.djangoproject.com/browser/django/trunk/django/core/management/commands/test.py
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/django-developers?hl=en.
>
>
This is needed so that the process will exit with the correct status code.
Note that this doesn't prevent you from calling it, you just need to catch
the SystemExit exception.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." -- Evelyn Beatrice Hall (summarizing Voltaire)
"The people's good is the highest law." -- Cicero

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to