Commit f1d06d74 authored by Stavros Sachtouris's avatar Stavros Sachtouris
Browse files

Create logger before help message

parent 40b1ed91
......@@ -241,6 +241,9 @@ def _init_session(arguments, is_non_API=False):
_verbose = arguments['verbose'].value
_cnf = arguments['config']
_silent = arguments['silent'].value
_setup_logging(_silent, _debug, _verbose, _include)
if _help or is_non_API:
return None, None
......@@ -251,8 +254,6 @@ def _init_session(arguments, is_non_API=False):
if not (stdout.isatty() and _colors == 'on'):
from kamaki.cli.utils import remove_colors
remove_colors()
_silent = arguments['silent'].value
_setup_logging(_silent, _debug, _verbose, _include)
cloud = arguments['cloud'].value or _cnf.value.get(
'global', 'default_cloud')
......@@ -327,24 +328,25 @@ def _init_session(arguments, is_non_API=False):
def _load_spec_module(spec, arguments, module):
global kloger
if not spec:
return None
pkg = None
for location in cmd_spec_locations:
location += spec if location == '' else '.%s' % spec
try:
kloger.debug('Import %s from %s' % ([module], location))
pkg = __import__(location, fromlist=[module])
kloger.debug('\t...OK')
return pkg
except ImportError as ie:
kloger.debug('\t...Failed')
continue
if not pkg:
msg = 'Loading command group %s failed: %s' % (spec, ie)
try:
kloger.debug(msg)
except AttributeError:
print msg
print 'HINT: use a text editor to remove all global.*_cli'
print ' settings from the configuration file'
msg += '\nHINT: use a text editor to remove all global.*_cli'
msg += '\n\tsettings from the configuration file'
kloger.debug(msg)
return pkg
......
......@@ -246,19 +246,19 @@ class Config(RawConfigParser):
"""
checker = Config(self.path, with_defaults=False)
sections = checker.sections()
log.warning('Config file heuristic 1: old global section ?')
log.debug('Config file heuristic 1: old global section ?')
if 'global' in sections:
if checker.get('global', 'url') or checker.get('global', 'token'):
log.warning('..... config file has an old global section')
log.debug('..... config file has an old global section')
return 0.8
log.warning('........ nope')
log.warning('Config file heuristic 2: Any cloud sections ?')
log.debug('........ nope')
log.debug('Config file heuristic 2: Any cloud sections ?')
if CLOUD_PREFIX in sections:
for r in self.keys(CLOUD_PREFIX):
log.warning('... found cloud "%s"' % r)
log.debug('... found cloud "%s"' % r)
return 0.9
log.warning('........ nope')
log.warning('All heuristics failed, cannot decide')
log.debug('........ nope')
log.debug('All heuristics failed, cannot decide')
return 0.9
def get_cloud(self, cloud, option):
......
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