From b5c864cff7bfb0dbb2ba3dc53055d050e9a9de79 Mon Sep 17 00:00:00 2001 From: william wilberforce junior Date: Fri, 16 Dec 2016 13:45:05 +0800 Subject: [PATCH 1/4] using colorama when under windows system --- httpstat.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/httpstat.py b/httpstat.py index df4f396..3444e7f 100644 --- a/httpstat.py +++ b/httpstat.py @@ -15,6 +15,9 @@ import tempfile import subprocess +if os.name == 'nt': + from colorama import init + init() __version__ = '1.2.1' From 342af9963d09824005d0baf2d63385c61821b1c9 Mon Sep 17 00:00:00 2001 From: reorx Date: Fri, 16 Dec 2016 17:09:28 +0800 Subject: [PATCH 2/4] add windows flag, init colorama if os is windows --- httpstat.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/httpstat.py b/httpstat.py index df4f396..01b8bb6 100644 --- a/httpstat.py +++ b/httpstat.py @@ -24,6 +24,16 @@ if PY3: xrange = range +WIN = os.name == 'nt' + +if WIN: + try: + import colorama + except ImportError: + print('Please install colorama for better color support in Windows') + else: + colorama.init() + # Env class is copied from https://github.com/reorx/getenv/blob/master/getenv.py class Env(object): From adba1e31678db132443d14959232760baf9aefa8 Mon Sep 17 00:00:00 2001 From: reorx Date: Fri, 16 Dec 2016 17:13:01 +0800 Subject: [PATCH 3/4] add extras_require for windows, update readme --- README.md | 2 ++ setup.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/README.md b/README.md index 5eef0e2..9bfb581 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,8 @@ There are three ways to get `httpstat`: - Through homebrew (macOS only): `brew install httpstat` > For Windows users, @davecheney's [Go version](https://github.com/davecheney/httpstat) is suggested. → [download link](https://github.com/davecheney/httpstat/releases) +> +> Or install through `pip install httpstat[windows]` to have better support. ## Usage diff --git a/setup.py b/setup.py index fc5a556..189d76c 100644 --- a/setup.py +++ b/setup.py @@ -39,5 +39,8 @@ def get_long_description(): 'httpstat = httpstat:main' ] }, + extras_require={ + 'windows': ['colorama'], + }, license='License :: OSI Approved :: MIT License', ) From 6da2678de4b25b539db4b294f75dbc7067112776 Mon Sep 17 00:00:00 2001 From: reorx Date: Fri, 16 Dec 2016 17:19:07 +0800 Subject: [PATCH 4/4] remove duplicated --- httpstat.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/httpstat.py b/httpstat.py index 893b071..01b8bb6 100644 --- a/httpstat.py +++ b/httpstat.py @@ -15,9 +15,6 @@ import tempfile import subprocess -if os.name == 'nt': - from colorama import init - init() __version__ = '1.2.1'