# Licensed under the MIT License. See License.txt in the project root for license information. #--------------------------------------------------------------------------------------------- from __future__ import print_function, unicode_literals import sys import json import re import traceback from collections import OrderedDict from six import StringIO, text_type, u from azure.cli._util import CLIError import azure.cli._logging as _logging logger = _logging.get_az_logger(__name__) def _decode_str(output): if not isinstance(output, text_type): output = u(str(output)) return output class ComplexEncoder(json.JSONEncoder): def default(self, obj): #pylint: disable=method-hidden if isinstance(obj, bytes) and not isinstance(obj, str): return obj.decode() return json.JSONEncoder.default(self, obj) def format_json(obj): result = obj.result input_dict = result.__dict__ if hasattr(result, '__dict__') else result
#--------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. #--------------------------------------------------------------------------------------------- from .._profile import Profile import azure.cli._debug as _debug import azure.cli as cli import azure.cli._logging as _logging from azure.cli.application import APPLICATION logger = _logging.get_az_logger(__name__) def get_mgmt_service_client(client_type): client, _ = _get_mgmt_service_client(client_type) return client def get_subscription_service_client(client_type): return _get_mgmt_service_client(client_type, False) def configure_common_settings(client): _debug.allow_debug_connection(client) client.config.add_user_agent("AZURECLI/{}".format(cli.__version__)) for header, value in APPLICATION.session['headers'].items(): # We are working with the autorest team to expose the add_header # functionality of the generated client to avoid having to access # private members client._client.add_header(header, value) #pylint: disable=protected-access
def test_get_az_logger_module(self): az_module_logger = _logging.get_az_logger('azure.cli.module') self.assertEqual(az_module_logger.name, 'az.azure.cli.module')
def test_get_az_logger(self): az_logger = _logging.get_az_logger() self.assertEqual(az_logger.name, 'az')