Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23107 closed Bug (fixed)

--no-color option won't work for output of runserver command

Reported by: Hiroki Kiyohara Owned by: Areski Belaid
Component: Core (Management commands) Version: 1.7-rc-1
Severity: Normal Keywords:
Cc: areski@…, Tim Graham, hirokiky@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

The --no-color option won't work for output of runserver command.

python manage.py runserver --no-color
...

[26/Jul/2014 15:01:07] "GET / HTTP/1.1" 500 85001  # Colored

Ticket for --no-color feature did not include about WSGIServer https://code.djangoproject.com/ticket/19877
And, output of the WSGIServer will be colorized.
(actually output of the management command won't be colorized).

Attachments (1)

23107.diff (552 bytes ) - added by Hiroki Kiyohara 10 years ago.

Download all attachments as: .zip

Change History (16)

by Hiroki Kiyohara, 10 years ago

Attachment: 23107.diff added

comment:1 by Hiroki Kiyohara, 10 years ago

Has patch: set
Needs tests: set

Attached a patch to fix the behaviour.
I'll try to write tests and send PR (after Accepted).

It seems difficult to write test (Running debug server with --no-color option and checking the log).
So If you have some idea, please share.

Last edited 10 years ago by Hiroki Kiyohara (previous) (diff)

comment:2 by Hiroki Kiyohara, 10 years ago

Owner: changed from nobody to Hiroki Kiyohara
Status: newassigned

comment:3 by Areski Belaid, 10 years ago

I tried the patch to add a review and it didn't worked for me, so I made the following pull request:
https://github.com/django/django/pull/2989

I think this need a more advanced Django dev to review it and maybe put us in the right direction.

comment:4 by Areski Belaid, 10 years ago

Cc: areski@… added

comment:5 by Tim Graham, 10 years ago

Cc: Tim Graham added
Triage Stage: UnreviewedAccepted

comment:6 by Hiroki Kiyohara, 10 years ago

Cc: hirokiky@… added
Owner: Hiroki Kiyohara removed
Status: assignednew

@areski Thanks for your patch. Your solution is direct and seems good. I deassign from this patch.

comment:7 by Areski Belaid, 10 years ago

Owner: set to Areski Belaid
Status: newassigned

comment:8 by Areski Belaid, 10 years ago

I'm taking a much more simplistic approach to solve this, same as mentioned in the original patch but with a correction.
https://github.com/django/django/pull/2998

comment:9 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 67d7da5fb9498b811f0168f5df2308ad4743027f:

Fixed #23107 -- Made runserver output respect --no-color.

comment:10 by Tim Graham <timograham@…>, 10 years ago

In 7cb4a82eaf2c6b59a80699ae91b63180eb8a47ef:

[1.7.x] Fixed #23107 -- Made runserver output respect --no-color.

Backport of 67d7da5fb9 from master

comment:11 by Hiroki Kiyohara, 10 years ago

Thank you guys.
I think it's better to credit @timo and me on the commit log.
https://docs.djangoproject.com/en/1.7/internals/contributing/committing-code/#committing-guidelines

comment:12 by Tim Graham, 10 years ago

Sorry, I forgot to add that.

comment:13 by Loic Bistuer, 10 years ago

I don't think modifying the environment is an appropriate fix, if you use call_command(no_color=True), every other call_command() won't have color. I'm in favor of a revert.

comment:14 by Loic Bistuer, 10 years ago

Sadly it doesn't seem that we have any other ways than the environment to reach WSGIRequestHandler. In https://github.com/django/django/pull/3391 I limit the change of environment to the runserver command which is IMO acceptable considering this command runs forever.

comment:15 by Loic Bistuer <loic.bistuer@…>, 10 years ago

In c34e13e17c664ea43b85572428bcf74c7509db3f:

Fixed #23107 -- Made runserver output respect --no-color.

This commit reverts 67d7da5fb9498b811f0168f5df2308ad4743027f.

The previous fix changed the environment globally, which meant
that any call to call_command(no_color=True) prevented further
call_command with color.

This fix still relies on the environment because it's currently the only
way to reach WSGIRequestHandler, but it's now limited to the runserver
command. This seems an acceptable compromise considering runserver runs
indefinitely.

Thanks Tim Graham for the review.

Note: See TracTickets for help on using tickets.
Back to Top