Commit 5729a86b authored by Xavier Thompson's avatar Xavier Thompson

slapos/cli: Improve output printing

Before this commit, some slapos commands would output this warning:
```
  No handlers could be found for logger "cachecontrol.controller"
```

The affected commands included:
- slapos service list
- slapos service info
- slapos computer list
- slapos computer info
- slapos computer token
- slapos cache source
parent 6dbb5d49
......@@ -38,7 +38,7 @@ import prettytable
from slapos.grid import networkcache
from slapos.cli.config import ConfigCommand
from slapos.cli.list import resetLogger
from slapos.cli.command import resetLogger
from slapos.util import str2bytes
class CacheLookupCommand(ConfigCommand):
......
......@@ -29,12 +29,18 @@
import argparse
import functools
import logging
import os
import sys
from cliff import command
def resetLogger(logger):
logger.propagate = False
logger.addHandler(logging.StreamHandler(sys.stdout))
class Command(command.Command):
def get_parser(self, prog_name):
......
......@@ -27,23 +27,15 @@
#
##############################################################################
import logging
import pprint
import sys
from slapos.cli.command import resetLogger
from slapos.cli.config import ClientConfigCommand
from slapos.client import init, ClientConfig
from slapos.slap import ResourceNotReady, NotFoundError
def resetLogger(logger):
"""Remove all formatters, log files, etc."""
if not getattr(logger, 'parent', None):
return
handler = logger.parent.handlers[0]
logger.parent.removeHandler(handler)
logger.addHandler(logging.StreamHandler(sys.stdout))
class InfoCommand(ClientConfigCommand):
"""get information of an computer"""
......
......@@ -27,20 +27,13 @@
#
##############################################################################
import logging
import sys
import six
from slapos.cli.command import resetLogger
from slapos.cli.config import ClientConfigCommand
from slapos.client import init, ClientConfig
def resetLogger(logger):
"""Remove all formatters, log files, etc."""
if not getattr(logger, 'parent', None):
return
handler = logger.parent.handlers[0]
logger.parent.removeHandler(handler)
logger.addHandler(logging.StreamHandler(sys.stdout))
class ListCommand(ClientConfigCommand):
"""request an instance and get status and parameters of instance"""
......
......@@ -27,23 +27,15 @@
#
##############################################################################
import logging
import pprint
import sys
from slapos.cli.command import resetLogger
from slapos.cli.config import ClientConfigCommand
from slapos.client import init, ClientConfig
from slapos.slap import ResourceNotReady, NotFoundError
def resetLogger(logger):
"""Remove all formatters, log files, etc."""
if not getattr(logger, 'parent', None):
return
handler = logger.parent.handlers[0]
logger.parent.removeHandler(handler)
logger.addHandler(logging.StreamHandler(sys.stdout))
class TokenCommand(ClientConfigCommand):
"""get token for setup a computer"""
......
......@@ -27,23 +27,15 @@
#
##############################################################################
import logging
import pprint
import sys
from slapos.cli.command import resetLogger
from slapos.cli.config import ClientConfigCommand
from slapos.client import init, ClientConfig
from slapos.slap import ResourceNotReady, NotFoundError
def resetLogger(logger):
"""Remove all formatters, log files, etc."""
if not getattr(logger, 'parent', None):
return
handler = logger.parent.handlers[0]
logger.parent.removeHandler(handler)
logger.addHandler(logging.StreamHandler(sys.stdout))
class InfoCommand(ClientConfigCommand):
"""get status, software_release and parameters of an instance"""
......
......@@ -27,20 +27,13 @@
#
##############################################################################
import logging
import sys
import six
from slapos.cli.command import resetLogger
from slapos.cli.config import ClientConfigCommand
from slapos.client import init, ClientConfig
def resetLogger(logger):
"""Remove all formatters, log files, etc."""
if not getattr(logger, 'parent', None):
return
handler = logger.parent.handlers[0]
logger.parent.removeHandler(handler)
logger.addHandler(logging.StreamHandler(sys.stdout))
class ListCommand(ClientConfigCommand):
"""request an instance and get status and parameters of instance"""
......
......@@ -420,7 +420,7 @@ class SlapHateoasNavigator(HateoasNavigator):
assert len(hosting_subscription_list) <= 1, \
"There are more them one Hosting Subscription for this reference"
hosting_subscription_jio_key= None
hosting_subscription_jio_key = None
for hosting_subscription_candidate in hosting_subscription_list:
if hosting_subscription_candidate.get('title') == reference:
hosting_subscription_jio_key = hosting_subscription_candidate['relative_url']
......
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