# Path: smc/base/util.py
# def unicode_to_bytes(s, encoding='utf-8', errors='replace'):
#     """
#     Helper to convert unicode strings to bytes for data that needs to be
#     written to on output stream (i.e. terminal)
#     For Python 3 this should be called str_to_bytes
# 
#     :param str s: string to encode
#     :param str encoding: utf-8 by default
#     :param str errors: what to do when encoding fails
#     :return: byte string utf-8 encoded
#     """
#     return s if isinstance(s, str) else s.encode(encoding, errors)


import smc.api.web
from smc.base.util import unicode_to_bytes
    """

    def __init__(self, response=None):
        # Response is type <class 'requests.models.Response'>
        self.response = response
        self.code = None
        self.smcresult = smc.api.web.SMCResult()
        if response is not None:
            self._unpack_response()

    def _unpack_response(self):
        details = None
        self.code = self.response.status_code
        if self.response.headers.get('content-type') == 'application/json':
            try:
                data = self.response.json()
            except ValueError:
                message = 'No valid message returned from SMC server'
            else:
                message = data.get('message', None)
                details = data.get('details', None)
        else:  # it's not json
            if self.response.text:
                message = self.response.text
            else:
                message = "No message returned from SMC server"

        self.smcresult.code = self.code

        if details:

# Path: smc/base/util.py
# def unicode_to_bytes(s, encoding='utf-8', errors='replace'):
#     """
#     Helper to convert unicode strings to bytes for data that needs to be
#     written to on output stream (i.e. terminal)
#     For Python 3 this should be called str_to_bytes
# 
#     :param str s: string to encode
#     :param str encoding: utf-8 by default
#     :param str errors: what to do when encoding fails
#     :return: byte string utf-8 encoded
#     """
#     return s if isinstance(s, str) else s.encode(encoding, errors)


# Path: smc/api/exceptions.py
import smc.api.web
from smc.base.util import unicode_to_bytes

    """

    def __init__(self, response=None):
        # Response is type <class 'requests.models.Response'>
        self.response = response
        self.code = None
        self.smcresult = smc.api.web.SMCResult()
        if response is not None:
            self._unpack_response()

    def _unpack_response(self):
        details = None
        self.code = self.response.status_code
        if self.response.headers.get('content-type') == 'application/json':
            try:
                data = self.response.json()
            except ValueError:
                message = 'No valid message returned from SMC server'
            else:
                message = data.get('message', None)
                details = data.get('details', None)
        else:  # it's not json
            if self.response.text:
                message = self.response.text
            else:
                message = "No message returned from SMC server"

        self.smcresult.code = self.code

        if details:

            details = unicode_to_bytes(' '.join(details)) \