Exiting from a management command with a given exit status

37 views
Skip to first unread message

Johannes Schneider

unread,
Jan 23, 2014, 9:06:42 AM1/23/14
to django...@googlegroups.com
Hi List,
see the question in the subject. I want to return from a management
command with a given exit code. How can this be done?

bg,
Johannes

--
Johannes Schneider
Webentwicklung
johannes....@galileo-press.de
Tel.: +49.228.42150.xxx

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Tel.: +49.228.42.150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Geschäftsführer: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn

Erik Cederstrand

unread,
Jan 23, 2014, 9:48:39 AM1/23/14
to Django Users
Den 23/01/2014 kl. 15.06 skrev Johannes Schneider <johannes....@galileo-press.de>:

> Hi List,
> see the question in the subject. I want to return from a management command with a given exit code. How can this be done?


class Command(BaseCommand):
def handle(self, *args, **options):
try:
# Something that may fail
except TheException:
# Clean up any transactions, open database connections etc.
import sys
sys.exit(123)


Erik

Johannes Schneider

unread,
Jan 24, 2014, 3:10:55 AM1/24/14
to django...@googlegroups.com
thnx,
I thought there might be a more django-like way.

On 23.01.2014 15:48, Erik Cederstrand wrote:
> import sys
> sys.exit(123)

James Bennett

unread,
Jan 24, 2014, 6:40:07 AM1/24/14
to django...@googlegroups.com
On Fri, Jan 24, 2014 at 2:10 AM, Johannes Schneider <johannes....@galileo-press.de> wrote:
thnx,
I thought there might be a more django-like way.

Using standard features of Python and its built-in libraries *is* the "Django-like way".
Reply all
Reply to author
Forward
0 new messages