Commit 49b479a7 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Merge branch 'develop' into feature-store

parents 745d938b fa984c2c
......@@ -43,6 +43,7 @@ from kamaki.cli.errors import CLIError
_help = False
_debug = False
_include = False
_verbose = False
_colors = False
kloger = None
......@@ -188,8 +189,9 @@ def _setup_logging(silent=False, debug=False, verbose=False, include=False):
add_handler('clients.send', logging.INFO, prefix='> ')
add_handler('clients.recv', logging.INFO, prefix='< ')
add_handler('kamaki', logging.INFO, prefix='(i): ')
elif include:
add_handler('clients.recv', logging.INFO)
if include:
add_handler('data.send', logging.INFO, prefix='>[data]: ')
add_handler('data.recv', logging.INFO, prefix='<[data]: ')
add_handler('kamaki', logging.WARNING, prefix='(warning): ')
global kloger
kloger = logging.getLogger('kamaki')
......@@ -200,6 +202,8 @@ def _init_session(arguments):
_help = arguments['help'].value
global _debug
_debug = arguments['debug'].value
global _include
_include = arguments['include'].value
global _verbose
_verbose = arguments['verbose'].value
global _colors
......@@ -208,7 +212,6 @@ def _init_session(arguments):
from kamaki.cli.utils import remove_colors
remove_colors()
_silent = arguments['silent'].value
_include = arguments['include'].value
_setup_logging(_silent, _debug, _verbose, _include)
......
......@@ -373,7 +373,7 @@ class ProgressBarArgument(FlagArgument):
_arguments = dict(config=_config_arg,
help=Argument(0, 'Show help message', ('-h', '--help')),
debug=FlagArgument('Include debug output', ('-d', '--debug')),
include=FlagArgument('Include protocol headers in the output',
include=FlagArgument('Include raw connection data in the output',
('-i', '--include')),
silent=FlagArgument('Do not output anything', ('-s', '--silent')),
verbose=FlagArgument('More info at response', ('-v', '--verbose')),
......
......@@ -93,8 +93,7 @@ class image_public(_init_image):
def main(self):
super(self.__class__, self).main()
filters = {}
for arg in set(
[
for arg in set([
'container_format',
'disk_format',
'name',
......
......@@ -40,7 +40,9 @@ from kamaki.clients.connection.errors import HTTPConnectionError
from kamaki.clients.connection.errors import HTTPResponseError
sendlog = logging.getLogger('clients.send')
datasendlog = logging.getLogger('data.send')
recvlog = logging.getLogger('clients.recv')
datarecvlog = logging.getLogger('data.recv')
class ClientError(Exception):
......@@ -187,6 +189,8 @@ class Client(object):
if data:
self.set_default_header('Content-Length', unicode(len(data)))
sendlog.info('perform a %s @ %s', method, self.base_url)
self.http_client.url = self.base_url
self.http_client.path = path
r = self.http_client.perform_request(method,
......@@ -203,13 +207,13 @@ class Client(object):
sendlog.info('\t%s: %s', key, val)
sendlog.info('')
if data:
sendlog.info(data[:256] + ' ...')
datasendlog.info(data)
recvlog.info('%d %s', r.status_code, r.status)
for key, val in r.headers.items():
recvlog.info('%s: %s', key, val)
if r.content:
recvlog.info(r.content[:256] + ' ...')
datarecvlog.info(r.content)
except (HTTPResponseError, HTTPConnectionError) as err:
from traceback import format_stack
......
......@@ -54,8 +54,11 @@ class ImageClient(Client):
"""
path = path4url('images', 'detail') if detail else path4url('images/')
async_params = {}
if isinstance(filters, dict):
self.http_client.params.update(filters)
for key, value in filters.items():
if value:
async_params[key] = value
if order.startswith('-'):
self.set_param('sort_dir', 'desc')
order = order[1:]
......@@ -63,7 +66,7 @@ class ImageClient(Client):
self.set_param('sort_dir', 'asc')
self.set_param('sort_key', order, iff=order)
r = self.get(path, success=200)
r = self.get(path, async_params=async_params, success=200)
return r.json
def get_meta(self, image_id):
......
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