Exemple #1
0
def _setup_logging(debug=False, verbose=False):
    """handle logging for clients package"""

    sfmt, rfmt = '> %(message)s', '< %(message)s'
    if debug:
        print('Logging location: %s' % logger.get_log_filename())
        logger.add_stream_logger('kamaki.clients.send', logging.DEBUG, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.DEBUG, rfmt)
        logger.add_stream_logger(__name__, logging.DEBUG)
    elif verbose:
        logger.add_stream_logger('kamaki.clients.send', logging.INFO, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.INFO, rfmt)
        logger.add_stream_logger(__name__, logging.INFO)
    # else:
    #     logger.add_stream_logger(__name__, logging.WARNING)
    global kloger
    kloger = logger.get_logger(__name__)
Exemple #2
0
def _setup_logging(debug=False, verbose=False):
    """handle logging for clients package"""

    sfmt, rfmt = '> %(message)s', '< %(message)s'
    if debug:
        print('Logging location: %s' % logger.get_log_filename())
        logger.add_stream_logger('kamaki.clients.send', logging.DEBUG, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.DEBUG, rfmt)
        logger.add_stream_logger(__name__, logging.DEBUG)
    elif verbose:
        logger.add_stream_logger('kamaki.clients.send', logging.INFO, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.INFO, rfmt)
        logger.add_stream_logger(__name__, logging.INFO)
    # else:
    #     logger.add_stream_logger(__name__, logging.WARNING)
    global kloger
    kloger = logger.get_logger(__name__)
Exemple #3
0
def _setup_logging(debug=False, verbose=False, _verbose_with_data=False):
    """handle logging for clients package"""

    sfmt, rfmt = '> %(message)s', '< %(message)s'
    if debug:
        print('Logging location: %s' % logger.get_log_filename())
        logger.add_stream_logger('kamaki.clients.send', logging.DEBUG, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.DEBUG, rfmt)
        logger.add_stream_logger(__name__, logging.DEBUG)
    elif verbose:
        logger.add_stream_logger('kamaki.clients.send', DEBUGV, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', DEBUGV, rfmt)
        logger.add_stream_logger(__name__, DEBUGV)
    # else:
    #     logger.add_stream_logger(__name__, logging.WARNING)
    if _verbose_with_data:
        from kamaki import clients
        clients.Client.LOG_DATA = True
    global kloger
    kloger = logger.get_logger(__name__)
Exemple #4
0
def _setup_logging(debug=False, verbose=False, _verbose_with_data=False):
    """handle logging for clients package"""

    sfmt, rfmt = '> %(message)s', '< %(message)s'
    if debug:
        print('Logging location: %s' % logger.get_log_filename())
        logger.add_stream_logger('kamaki.clients.send', logging.DEBUG, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', logging.DEBUG, rfmt)
        logger.add_stream_logger(__name__, logging.DEBUG)
    elif verbose:
        logger.add_stream_logger('kamaki.clients.send', DEBUGV, sfmt)
        logger.add_stream_logger('kamaki.clients.recv', DEBUGV, rfmt)
        logger.add_stream_logger(__name__, DEBUGV)
    # else:
    #     logger.add_stream_logger(__name__, logging.WARNING)
    if _verbose_with_data:
        from kamaki import clients
        clients.Client.LOG_DATA = True
    global kloger
    kloger = logger.get_logger(__name__)
Exemple #5
0
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

from sys import stdout, stderr
from re import compile as regex_compile
from os import walk, path
from json import dumps
from locale import getpreferredencoding

from kamaki.cli.logger import get_logger
from kamaki.cli.errors import raiseCLIError
from kamaki.clients.utils import escape_ctrl_chars

INDENT_TAB = 4
log = get_logger(__name__)
pref_enc = getpreferredencoding()


suggest = dict(ansicolors=dict(
    active=False,
    url='#install-ansicolors',
    description='Add colors to console responses'))

try:
    from colors import magenta, red, yellow, bold
except ImportError:
    red = yellow = magenta = bold = lambda x: x
    suggest['ansicolors']['active'] = True

Exemple #6
0
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

from kamaki.cli.logger import get_logger

log = get_logger('kamaki.cli')


class CLIError(Exception):

    def __init__(self, message, details=[], importance=0):
        """
        :param message: is the main message of the Error
        :param defaults: is a list of previous errors
        :param importance: of the output for the user (0, 1, 2, 3)
        """
        message += '' if message and message.endswith('\n') else '\n'
        super(CLIError, self).__init__(message)
        self.message = message
        self.details = (list(details) if (
            isinstance(details, list) or isinstance(details, tuple)) else [
Exemple #7
0
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

from sys import stdout, stderr
from re import compile as regex_compile
from os import walk, path
from json import dumps
from locale import getpreferredencoding

from kamaki.cli.logger import get_logger
from kamaki.cli.errors import raiseCLIError
from kamaki.clients.utils import escape_ctrl_chars

INDENT_TAB = 4
log = get_logger(__name__)
pref_enc = getpreferredencoding()

suggest = dict(ansicolors=dict(active=False,
                               url='#install-ansicolors',
                               description='Add colors to console responses'))

try:
    from colors import magenta, red, yellow, bold
except ImportError:
    red = yellow = magenta = bold = lambda x: x
    suggest['ansicolors']['active'] = True


def remove_colors():
    global bold
Exemple #8
0
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# The views and conclusions contained in the software and
# documentation are those of the authors and should not be
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.

from kamaki.cli.logger import get_logger

log = get_logger('kamaki.cli')


class CLIError(Exception):
    def __init__(self, message, details=[], importance=0):
        """
        :param message: is the main message of the Error
        :param defaults: is a list of previous errors
        :param importance: of the output for the user (0, 1, 2, 3)
        """
        message += '' if message and message.endswith('\n') else '\n'
        super(CLIError, self).__init__(message)
        self.message = message
        self.details = (list(details) if (
            isinstance(details, list) or isinstance(details, tuple)) else
                        ['%s' % details]) if details else []
Exemple #9
0
 def test_get_logger(self, GL):
     from kamaki.cli.logger import get_logger
     get_logger('my logger name')
     GL.assert_called_once_with('my logger name')
Exemple #10
0
 def test_get_logger(self, GL):
     from kamaki.cli.logger import get_logger
     get_logger('my logger name')
     GL.assert_called_once_with('my logger name')