X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Ftools%2Fpresentation%2Fpal_errors.py;fp=resources%2Ftools%2Fpresentation%2Ferrors.py;h=649c86cde82cb3ffd74dcacb95b40de6ba20a630;hb=9063ade3cc3652a320b8f81a6b5211fcc7ab087d;hp=64084f6a4034e132e5e5650e77fa50d38f575200;hpb=32c7c25c5bfa7577543129dec02e790a88b60a2b;p=csit.git diff --git a/resources/tools/presentation/errors.py b/resources/tools/presentation/pal_errors.py similarity index 74% rename from resources/tools/presentation/errors.py rename to resources/tools/presentation/pal_errors.py index 64084f6a40..649c86cde8 100644 --- a/resources/tools/presentation/errors.py +++ b/resources/tools/presentation/pal_errors.py @@ -1,4 +1,4 @@ -# 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: @@ -29,21 +29,21 @@ class PresentationError(Exception): - 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 @@ -59,13 +59,14 @@ class PresentationError(Exception): 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)