Closed wyattanderson closed 10 years ago
We shouldn't ignore the return value as is the case now, but I wonder, is raising a CommandError the correct (only?) way to determine the exit code of a Django command? Otherwise, it might be nicer to just set the exit code as desired.
Yeah, it's sub-optimal, but as far as I can tell from reading the relevant Django source code, there's no way to raise a CommandError
with an exit code other than 1.
It does seem that raising a CommandError
is the right way to indicate failure in a management command, so I'm hesitant to bypass that by calling sys.exit
directly, which is the only way I can think of to preserve the return code.
The webassets script will return a numeric error value in certain failure cases (such as FilterErrors raised by some filters) instead of raising an exception. Since run_with_argv is called directly here, we need to check its return value and raise a Django CommandError if the build command indicated a failure.