Re: First request - Modify django.core.management.color with settings option

64 views
Skip to first unread message

Florian Apolloner

unread,
Dec 19, 2012, 4:08:23 PM12/19/12
to django-d...@googlegroups.com
I dislike a setting for this, an optional environment variable would make more sense imo (since you usually don't want to set this for one project but all…).

Cheers,
Florian

Alex Gaynor

unread,
Dec 19, 2012, 4:09:11 PM12/19/12
to django-d...@googlegroups.com
I too think a setting is inappropriate for this, I'm also a little skeptical of an env var, is this not a bug with PyCharm?

Alex



--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/pV58KKtlpUMJ.

To post to this group, send email to django-d...@googlegroups.com.
To unsubscribe from this group, send email to django-develop...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.



--
"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

Alex Ogier

unread,
Dec 19, 2012, 5:45:08 PM12/19/12
to django-d...@googlegroups.com
Well, most GNU command line utilities have an option --color=always|auto|never that defaults to auto. Seems like it works for them, so replicating it for management commands makes more sense than an environment variable to me.

Best,
Alex Ogier

Russell Keith-Magee

unread,
Dec 19, 2012, 7:10:50 PM12/19/12
to django-d...@googlegroups.com

Agreed - a --color command line flag makes more sense to me, and a lot more sense than a setting. I *might* be able to be convinced about an environment variable too (since the environment variable DJANGO_COLORS is already used to set the palette), but frankly, Alex Gaynor's argument about this being a bug in PyCharm is a lot more convincing.

Yours,
Russ Magee %-)

Rafał Stożek

unread,
Dec 19, 2012, 2:07:09 PM12/19/12
to django-d...@googlegroups.com
Environment variable may be a better choice.

On Wed, Dec 19, 2012 at 3:41 PM, Steven Klass <skl...@pivotalenergysolutions.com> wrote:
Hi all,

I know a number of us use PyCharm/Eclipse for Django development.  As such the interpreters run `./manage.py runserver` directly from within the IDE.  The problem is that when using this approach sys.stdout does not have the method `isatty()`.  attached to is.  This results in no color for PyCharm / Eclipse people.  There are a number of ways to support this but the simplest and most scalable IMHO is to be able to override this with a settings option to force color.  Is this cool to put a feature request in, and what's the probability of it happening?


from django.conf import settings

def supports_color():
    """
    Returns True if the running system's terminal supports color, and False
    otherwise.
    """
    unsupported_platform = (sys.platform in ('win32', 'Pocket PC'))
    # isatty is not always implemented, #6223.
    ## is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
    is_a_tty = (hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()) \
      or settings.SUPPORTS_COLOR
    if unsupported_platform or not is_a_tty:
        return False
    return True

Thanks

---

Steven Klass

--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/-NL44J422mAJ.
Reply all
Reply to author
Forward
0 new messages