Commit 0d735aaf authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Suggest ansicolors, progress when missing (#3367)

parent 4c587cf9
...@@ -65,14 +65,6 @@ The following steps describe a command-line approach, but any graphic package ma ...@@ -65,14 +65,6 @@ The following steps describe a command-line approach, but any graphic package ma
$ sudo apt-get install kamaki $ sudo apt-get install kamaki
Install ansicolors and/or progress (Optional but recommended)
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
.. code-block:: console
$ sudo apt-get install python-ansicolors
$ sudo apt-get install python-progress
.. _installing-from-source-ref: .. _installing-from-source-ref:
Installing from source (git repos.) Installing from source (git repos.)
...@@ -136,18 +128,41 @@ and then installed by the setup script: ...@@ -136,18 +128,41 @@ and then installed by the setup script:
$ cd kamaki $ cd kamaki
$ ./setup build install $ ./setup build install
Install progress and/or ansicolors (optional) Install ansicolors / progress
""""""""""""""""""""""""""""""""""""""""""""" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Packages **ansicolors** and **progress** are not required for running kamaki, but
they are recommended as a user experience improvement. In specific, ansicolors
adds colors to kamaki responses and progress adds progressbars to the commands
that can make use of it (*/store download*, */store upload*, */server wait* etc.)
progress: command-line progress bars (in some commands) Debian and Ubuntu
"""""""""""""""""
ansicolors: color kamaki output (can switched on and off in `setup <setup.html>`_) Follow the `Debian <#debian>`_ or `Ubuntu <#ubuntu>`_ installation procedure described earlier
and then type:
.. code-block:: console .. code-block:: console
$ pip install progress #For ansicolors
$ sudo apt-get install python-ansicolors
# For progress
$ sudo apt-get install python-progress
From source
"""""""""""
If setuptools is not installed, `install them <http://pypi.python.org/pypi/setuptools>`_ and then type:
.. code-block:: console
#For ansicolors
$ pip install ansicolors $ pip install ansicolors
#For progress
$ pip install progress
Mac OS X Mac OS X
-------- --------
......
...@@ -390,6 +390,9 @@ def main(): ...@@ -390,6 +390,9 @@ def main():
_init_session(parser.arguments) _init_session(parser.arguments)
from kamaki.cli.utils import suggest_missing
suggest_missing()
if parser.unparsed: if parser.unparsed:
run_one_cmd(exe, parser) run_one_cmd(exe, parser)
elif _help: elif _help:
......
...@@ -37,6 +37,16 @@ from time import sleep ...@@ -37,6 +37,16 @@ from time import sleep
from kamaki.cli.errors import raiseCLIError from kamaki.cli.errors import raiseCLIError
suggest = dict(
ansicolors=dict(
active=False,
url='#install-ansicolors-progress',
description='Add colors to console responses'),
progress=dict(
active=False,
url='#install-ansicolors-progress',
description='Add progress bars to some commands'))
try: try:
from colors import magenta, red, yellow, bold from colors import magenta, red, yellow, bold
except ImportError: except ImportError:
...@@ -44,6 +54,24 @@ except ImportError: ...@@ -44,6 +54,24 @@ except ImportError:
def dummy(val): def dummy(val):
return val return val
red = yellow = magenta = bold = dummy red = yellow = magenta = bold = dummy
suggest['ansicolors']['active'] = True
try:
from progress.bar import ShadyBar
except ImportError:
suggest['progress']['active'] = True
def suggest_missing(miss=None):
global suggest
kamaki_docs = 'http://www.synnefo.org/docs/kamaki/latest'
for k, v in (miss, suggest[miss]) if miss else suggest.items():
if v['active'] and stdout.isatty():
print('Suggestion: for better user experience install %s' % k)
print('\t%s' % v['description'])
print('\tIt is easy, here are the instructions:')
print('\t%s/installation.html%s' % (kamaki_docs, v['url']))
print('')
def remove_colors(): def remove_colors():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment