-# Copyright (c) 2017 Cisco and/or its affiliates.
+# Copyright (c) 2019 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
- relevant data if there are any collected (optional parameter details).
"""
- log_exception = {"DEBUG": logging.debug,
- "INFO": logging.info,
- "WARNING": logging.warning,
- "ERROR": logging.error,
- "CRITICAL": logging.critical}
+ log_exception = {u"DEBUG": logging.debug,
+ u"INFO": logging.info,
+ u"WARNING": logging.warning,
+ u"ERROR": logging.error,
+ u"CRITICAL": logging.critical}
- def __init__(self, msg, details='', level="CRITICAL"):
+ def __init__(self, msg, details=u'', level=u"CRITICAL"):
"""Sets the exception message and the level.
:param msg: Short description of the encountered problem.
:param details: Relevant messages if there are any collected, e.g.,
- from caught exception (optional parameter details), or relevant data if
- there are any collected (optional parameter details).
+ from caught exception (optional parameter details), or relevant data
+ if there are any collected (optional parameter details).
:param level: Level of the error, possible choices are: "DEBUG", "INFO",
- "WARNING", "ERROR" and "CRITICAL".
+ "WARNING", "ERROR" and "CRITICAL".
:type msg: str
:type details: str
:type level: str
if self._details:
self.log_exception[self._level](self._details)
except KeyError:
- print("Wrong log level.")
+ print(u"Wrong log level.")
sys.exit(1)
def __repr__(self):
return (
- "PresentationError(msg={msg!r},details={dets!r},level={level!r})".
- format(msg=self._msg, dets=self._details, level=self._level))
+ f"PresentationError(msg={self._msg!r},details={self._details!r},"
+ f"level={self._level!r})"
+ )
def __str__(self):
return str(self._msg)