Sync BaseTool trunk (version r2649) into EDKII BaseTools.
Signed-off-by: Gao, Liming <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15188 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@@ -17,4 +17,4 @@
|
||||
Build version information
|
||||
'''
|
||||
|
||||
gBUILD_VERSION = "Build 2640"
|
||||
gBUILD_VERSION = "Build 2649"
|
||||
|
@@ -1,20 +1,20 @@
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Core init file
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Core init file
|
||||
'''
|
@@ -1,20 +1,20 @@
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
GenMetaFile
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
GenMetaFile
|
||||
'''
|
@@ -93,7 +93,7 @@ class _ExprBase:
|
||||
|
||||
## IsCurrentOp
|
||||
#
|
||||
# @param OpList: option list
|
||||
# @param OpList: option list
|
||||
#
|
||||
def IsCurrentOp(self, OpList):
|
||||
self.SkipWhitespace()
|
||||
|
@@ -1,99 +1,99 @@
|
||||
## @file
|
||||
# This file is used to define common static strings and global data used by UPT
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
'''
|
||||
GlobalData
|
||||
'''
|
||||
|
||||
#
|
||||
# The workspace directory
|
||||
#
|
||||
gWORKSPACE = '.'
|
||||
|
||||
#
|
||||
# INF module directory
|
||||
#
|
||||
gINF_MODULE_DIR = "."
|
||||
gINF_MODULE_NAME = ''
|
||||
|
||||
#
|
||||
# the directory to holds upt related files
|
||||
#
|
||||
gUPT_DIR = r"Conf/upt/"
|
||||
|
||||
#
|
||||
# Log file for invalid meta-data files during force removing
|
||||
#
|
||||
gINVALID_MODULE_FILE = gUPT_DIR + r"Invalid_Modules.log"
|
||||
|
||||
#
|
||||
# File name for content zip file in the distribution
|
||||
#
|
||||
gCONTENT_FILE = "dist.content"
|
||||
|
||||
#
|
||||
# File name for XML file in the distibution
|
||||
#
|
||||
gDESC_FILE = 'dist.pkg'
|
||||
|
||||
#
|
||||
# Case Insensitive flag
|
||||
#
|
||||
gCASE_INSENSITIVE = ''
|
||||
|
||||
#
|
||||
# All Files dictionary
|
||||
#
|
||||
gALL_FILES = {}
|
||||
|
||||
#
|
||||
# Database instance
|
||||
#
|
||||
gDB = None
|
||||
|
||||
#
|
||||
# list for files that are found in module level but not in INF files,
|
||||
# items are (File, ModulePath), all these should be relative to $(WORKSPACE)
|
||||
#
|
||||
gMISS_FILE_IN_MODLIST = []
|
||||
|
||||
#
|
||||
# Global Current Line
|
||||
#
|
||||
gINF_CURRENT_LINE = None
|
||||
|
||||
#
|
||||
# Global pkg list
|
||||
#
|
||||
gWSPKG_LIST = []
|
||||
|
||||
#
|
||||
# Flag used to take WARN as ERROR.
|
||||
# By default, only ERROR message will break the tools execution.
|
||||
#
|
||||
gWARNING_AS_ERROR = False
|
||||
|
||||
#
|
||||
# Used to specify the temp directory to hold the unpacked distribution files
|
||||
#
|
||||
gUNPACK_DIR = None
|
||||
|
||||
#
|
||||
# Flag used to mark whether the INF file is Binary INF or not.
|
||||
#
|
||||
gIS_BINARY_INF = False
|
||||
#
|
||||
# Used by Library instance parser
|
||||
# {FilePath: FileObj}
|
||||
#
|
||||
## @file
|
||||
# This file is used to define common static strings and global data used by UPT
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
'''
|
||||
GlobalData
|
||||
'''
|
||||
|
||||
#
|
||||
# The workspace directory
|
||||
#
|
||||
gWORKSPACE = '.'
|
||||
|
||||
#
|
||||
# INF module directory
|
||||
#
|
||||
gINF_MODULE_DIR = "."
|
||||
gINF_MODULE_NAME = ''
|
||||
|
||||
#
|
||||
# the directory to holds upt related files
|
||||
#
|
||||
gUPT_DIR = r"Conf/upt/"
|
||||
|
||||
#
|
||||
# Log file for invalid meta-data files during force removing
|
||||
#
|
||||
gINVALID_MODULE_FILE = gUPT_DIR + r"Invalid_Modules.log"
|
||||
|
||||
#
|
||||
# File name for content zip file in the distribution
|
||||
#
|
||||
gCONTENT_FILE = "dist.content"
|
||||
|
||||
#
|
||||
# File name for XML file in the distibution
|
||||
#
|
||||
gDESC_FILE = 'dist.pkg'
|
||||
|
||||
#
|
||||
# Case Insensitive flag
|
||||
#
|
||||
gCASE_INSENSITIVE = ''
|
||||
|
||||
#
|
||||
# All Files dictionary
|
||||
#
|
||||
gALL_FILES = {}
|
||||
|
||||
#
|
||||
# Database instance
|
||||
#
|
||||
gDB = None
|
||||
|
||||
#
|
||||
# list for files that are found in module level but not in INF files,
|
||||
# items are (File, ModulePath), all these should be relative to $(WORKSPACE)
|
||||
#
|
||||
gMISS_FILE_IN_MODLIST = []
|
||||
|
||||
#
|
||||
# Global Current Line
|
||||
#
|
||||
gINF_CURRENT_LINE = None
|
||||
|
||||
#
|
||||
# Global pkg list
|
||||
#
|
||||
gWSPKG_LIST = []
|
||||
|
||||
#
|
||||
# Flag used to take WARN as ERROR.
|
||||
# By default, only ERROR message will break the tools execution.
|
||||
#
|
||||
gWARNING_AS_ERROR = False
|
||||
|
||||
#
|
||||
# Used to specify the temp directory to hold the unpacked distribution files
|
||||
#
|
||||
gUNPACK_DIR = None
|
||||
|
||||
#
|
||||
# Flag used to mark whether the INF file is Binary INF or not.
|
||||
#
|
||||
gIS_BINARY_INF = False
|
||||
#
|
||||
# Used by Library instance parser
|
||||
# {FilePath: FileObj}
|
||||
#
|
||||
gLIBINSTANCEDICT = {}
|
File diff suppressed because it is too large
Load Diff
@@ -1,20 +1,20 @@
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Xml
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Xml
|
||||
'''
|
@@ -1,20 +1,20 @@
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Library
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Library
|
||||
'''
|
@@ -1,325 +1,325 @@
|
||||
## @file
|
||||
# This file implements the log mechanism for Python tools.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Logger
|
||||
'''
|
||||
|
||||
## Import modules
|
||||
from sys import argv
|
||||
from sys import stdout
|
||||
from sys import stderr
|
||||
import os.path
|
||||
from os import remove
|
||||
from logging import getLogger
|
||||
from logging import Formatter
|
||||
from logging import StreamHandler
|
||||
from logging import FileHandler
|
||||
from traceback import extract_stack
|
||||
|
||||
from Logger.ToolError import FatalError
|
||||
from Logger.ToolError import WARNING_AS_ERROR
|
||||
from Logger.ToolError import gERROR_MESSAGE
|
||||
from Logger.ToolError import UNKNOWN_ERROR
|
||||
from Library import GlobalData
|
||||
|
||||
#
|
||||
# Log level constants
|
||||
#
|
||||
DEBUG_0 = 1
|
||||
DEBUG_1 = 2
|
||||
DEBUG_2 = 3
|
||||
DEBUG_3 = 4
|
||||
DEBUG_4 = 5
|
||||
DEBUG_5 = 6
|
||||
DEBUG_6 = 7
|
||||
DEBUG_7 = 8
|
||||
DEBUG_8 = 9
|
||||
DEBUG_9 = 10
|
||||
VERBOSE = 15
|
||||
INFO = 20
|
||||
WARN = 30
|
||||
QUIET = 40
|
||||
QUIET_1 = 41
|
||||
ERROR = 50
|
||||
SILENT = 60
|
||||
|
||||
IS_RAISE_ERROR = True
|
||||
SUPRESS_ERROR = False
|
||||
|
||||
#
|
||||
# Tool name
|
||||
#
|
||||
_TOOL_NAME = os.path.basename(argv[0])
|
||||
#
|
||||
# For validation purpose
|
||||
#
|
||||
_LOG_LEVELS = [DEBUG_0, DEBUG_1, DEBUG_2, DEBUG_3, DEBUG_4, DEBUG_5, DEBUG_6, \
|
||||
DEBUG_7, DEBUG_8, DEBUG_9, VERBOSE, WARN, INFO, ERROR, QUIET, \
|
||||
QUIET_1, SILENT]
|
||||
#
|
||||
# For DEBUG level (All DEBUG_0~9 are applicable)
|
||||
#
|
||||
_DEBUG_LOGGER = getLogger("tool_debug")
|
||||
_DEBUG_FORMATTER = Formatter("[%(asctime)s.%(msecs)d]: %(message)s", \
|
||||
datefmt="%H:%M:%S")
|
||||
#
|
||||
# For VERBOSE, INFO, WARN level
|
||||
#
|
||||
_INFO_LOGGER = getLogger("tool_info")
|
||||
_INFO_FORMATTER = Formatter("%(message)s")
|
||||
#
|
||||
# For ERROR level
|
||||
#
|
||||
_ERROR_LOGGER = getLogger("tool_error")
|
||||
_ERROR_FORMATTER = Formatter("%(message)s")
|
||||
|
||||
#
|
||||
# String templates for ERROR/WARN/DEBUG log message
|
||||
#
|
||||
_ERROR_MESSAGE_TEMPLATE = \
|
||||
('\n\n%(tool)s...\n%(file)s(%(line)s): error %(errorcode)04X: %(msg)s\n\t%(extra)s')
|
||||
|
||||
__ERROR_MESSAGE_TEMPLATE_WITHOUT_FILE = \
|
||||
'\n\n%(tool)s...\n : error %(errorcode)04X: %(msg)s\n\t%(extra)s'
|
||||
|
||||
_WARNING_MESSAGE_TEMPLATE = '%(tool)s...\n%(file)s(%(line)s): warning: %(msg)s'
|
||||
_WARNING_MESSAGE_TEMPLATE_WITHOUT_FILE = '%(tool)s: : warning: %(msg)s'
|
||||
_DEBUG_MESSAGE_TEMPLATE = '%(file)s(%(line)s): debug: \n %(msg)s'
|
||||
|
||||
|
||||
#
|
||||
# Log INFO message
|
||||
#
|
||||
#Info = _INFO_LOGGER.info
|
||||
|
||||
def Info(msg, *args, **kwargs):
|
||||
_INFO_LOGGER.info(msg, *args, **kwargs)
|
||||
|
||||
#
|
||||
# Log information which should be always put out
|
||||
#
|
||||
def Quiet(msg, *args, **kwargs):
|
||||
_ERROR_LOGGER.error(msg, *args, **kwargs)
|
||||
|
||||
## Log debug message
|
||||
#
|
||||
# @param Level DEBUG level (DEBUG0~9)
|
||||
# @param Message Debug information
|
||||
# @param ExtraData More information associated with "Message"
|
||||
#
|
||||
def Debug(Level, Message, ExtraData=None):
|
||||
if _DEBUG_LOGGER.level > Level:
|
||||
return
|
||||
if Level > DEBUG_9:
|
||||
return
|
||||
#
|
||||
# Find out the caller method information
|
||||
#
|
||||
CallerStack = extract_stack()[-2]
|
||||
TemplateDict = {
|
||||
"file" : CallerStack[0],
|
||||
"line" : CallerStack[1],
|
||||
"msg" : Message,
|
||||
}
|
||||
|
||||
if ExtraData != None:
|
||||
LogText = _DEBUG_MESSAGE_TEMPLATE % TemplateDict + "\n %s" % ExtraData
|
||||
else:
|
||||
LogText = _DEBUG_MESSAGE_TEMPLATE % TemplateDict
|
||||
|
||||
_DEBUG_LOGGER.log(Level, LogText)
|
||||
|
||||
## Log verbose message
|
||||
#
|
||||
# @param Message Verbose information
|
||||
#
|
||||
def Verbose(Message):
|
||||
return _INFO_LOGGER.log(VERBOSE, Message)
|
||||
|
||||
## Log warning message
|
||||
#
|
||||
# Warning messages are those which might be wrong but won't fail the tool.
|
||||
#
|
||||
# @param ToolName The name of the tool. If not given, the name of caller
|
||||
# method will be used.
|
||||
# @param Message Warning information
|
||||
# @param File The name of file which caused the warning.
|
||||
# @param Line The line number in the "File" which caused the warning.
|
||||
# @param ExtraData More information associated with "Message"
|
||||
#
|
||||
def Warn(ToolName, Message, File=None, Line=None, ExtraData=None):
|
||||
if _INFO_LOGGER.level > WARN:
|
||||
return
|
||||
#
|
||||
# if no tool name given, use caller's source file name as tool name
|
||||
#
|
||||
if ToolName == None or ToolName == "":
|
||||
ToolName = os.path.basename(extract_stack()[-2][0])
|
||||
|
||||
if Line == None:
|
||||
Line = "..."
|
||||
else:
|
||||
Line = "%d" % Line
|
||||
|
||||
TemplateDict = {
|
||||
"tool" : ToolName,
|
||||
"file" : File,
|
||||
"line" : Line,
|
||||
"msg" : Message,
|
||||
}
|
||||
|
||||
if File != None:
|
||||
LogText = _WARNING_MESSAGE_TEMPLATE % TemplateDict
|
||||
else:
|
||||
LogText = _WARNING_MESSAGE_TEMPLATE_WITHOUT_FILE % TemplateDict
|
||||
|
||||
if ExtraData != None:
|
||||
LogText += "\n %s" % ExtraData
|
||||
|
||||
_INFO_LOGGER.log(WARN, LogText)
|
||||
#
|
||||
# Raise an execption if indicated
|
||||
#
|
||||
if GlobalData.gWARNING_AS_ERROR == True:
|
||||
raise FatalError(WARNING_AS_ERROR)
|
||||
|
||||
## Log ERROR message
|
||||
#
|
||||
# Once an error messages is logged, the tool's execution will be broken by
|
||||
# raising an execption. If you don't want to break the execution later, you
|
||||
# can give "RaiseError" with "False" value.
|
||||
#
|
||||
# @param ToolName The name of the tool. If not given, the name of caller
|
||||
# method will be used.
|
||||
# @param ErrorCode The error code
|
||||
# @param Message Warning information
|
||||
# @param File The name of file which caused the error.
|
||||
# @param Line The line number in the "File" which caused the warning.
|
||||
# @param ExtraData More information associated with "Message"
|
||||
# @param RaiseError Raise an exception to break the tool's executuion if
|
||||
# it's True. This is the default behavior.
|
||||
#
|
||||
def Error(ToolName, ErrorCode, Message=None, File=None, Line=None, \
|
||||
ExtraData=None, RaiseError=IS_RAISE_ERROR):
|
||||
if ToolName:
|
||||
pass
|
||||
if Line == None:
|
||||
Line = "..."
|
||||
else:
|
||||
Line = "%d" % Line
|
||||
|
||||
if Message == None:
|
||||
if ErrorCode in gERROR_MESSAGE:
|
||||
Message = gERROR_MESSAGE[ErrorCode]
|
||||
else:
|
||||
Message = gERROR_MESSAGE[UNKNOWN_ERROR]
|
||||
|
||||
if ExtraData == None:
|
||||
ExtraData = ""
|
||||
|
||||
TemplateDict = {
|
||||
"tool" : _TOOL_NAME,
|
||||
"file" : File,
|
||||
"line" : Line,
|
||||
"errorcode" : ErrorCode,
|
||||
"msg" : Message,
|
||||
"extra" : ExtraData
|
||||
}
|
||||
|
||||
if File != None:
|
||||
LogText = _ERROR_MESSAGE_TEMPLATE % TemplateDict
|
||||
else:
|
||||
LogText = __ERROR_MESSAGE_TEMPLATE_WITHOUT_FILE % TemplateDict
|
||||
|
||||
if not SUPRESS_ERROR:
|
||||
_ERROR_LOGGER.log(ERROR, LogText)
|
||||
if RaiseError:
|
||||
raise FatalError(ErrorCode)
|
||||
|
||||
|
||||
## Initialize log system
|
||||
#
|
||||
def Initialize():
|
||||
#
|
||||
# Since we use different format to log different levels of message into
|
||||
# different place (stdout or stderr), we have to use different "Logger"
|
||||
# objects to do this.
|
||||
#
|
||||
# For DEBUG level (All DEBUG_0~9 are applicable)
|
||||
_DEBUG_LOGGER.setLevel(INFO)
|
||||
_DebugChannel = StreamHandler(stdout)
|
||||
_DebugChannel.setFormatter(_DEBUG_FORMATTER)
|
||||
_DEBUG_LOGGER.addHandler(_DebugChannel)
|
||||
#
|
||||
# For VERBOSE, INFO, WARN level
|
||||
#
|
||||
_INFO_LOGGER.setLevel(INFO)
|
||||
_InfoChannel = StreamHandler(stdout)
|
||||
_InfoChannel.setFormatter(_INFO_FORMATTER)
|
||||
_INFO_LOGGER.addHandler(_InfoChannel)
|
||||
#
|
||||
# For ERROR level
|
||||
#
|
||||
_ERROR_LOGGER.setLevel(INFO)
|
||||
_ErrorCh = StreamHandler(stderr)
|
||||
_ErrorCh.setFormatter(_ERROR_FORMATTER)
|
||||
_ERROR_LOGGER.addHandler(_ErrorCh)
|
||||
|
||||
|
||||
## Set log level
|
||||
#
|
||||
# @param Level One of log level in _LogLevel
|
||||
#
|
||||
def SetLevel(Level):
|
||||
if Level not in _LOG_LEVELS:
|
||||
Info("Not supported log level (%d). Use default level instead." % \
|
||||
Level)
|
||||
Level = INFO
|
||||
_DEBUG_LOGGER.setLevel(Level)
|
||||
_INFO_LOGGER.setLevel(Level)
|
||||
_ERROR_LOGGER.setLevel(Level)
|
||||
|
||||
## Get current log level
|
||||
#
|
||||
def GetLevel():
|
||||
return _INFO_LOGGER.getEffectiveLevel()
|
||||
|
||||
## Raise up warning as error
|
||||
#
|
||||
def SetWarningAsError():
|
||||
GlobalData.gWARNING_AS_ERROR = True
|
||||
|
||||
## Specify a file to store the log message as well as put on console
|
||||
#
|
||||
# @param LogFile The file path used to store the log message
|
||||
#
|
||||
def SetLogFile(LogFile):
|
||||
if os.path.exists(LogFile):
|
||||
remove(LogFile)
|
||||
|
||||
_Ch = FileHandler(LogFile)
|
||||
_Ch.setFormatter(_DEBUG_FORMATTER)
|
||||
_DEBUG_LOGGER.addHandler(_Ch)
|
||||
|
||||
_Ch = FileHandler(LogFile)
|
||||
_Ch.setFormatter(_INFO_FORMATTER)
|
||||
_INFO_LOGGER.addHandler(_Ch)
|
||||
|
||||
_Ch = FileHandler(LogFile)
|
||||
_Ch.setFormatter(_ERROR_FORMATTER)
|
||||
_ERROR_LOGGER.addHandler(_Ch)
|
||||
|
||||
|
||||
|
||||
## @file
|
||||
# This file implements the log mechanism for Python tools.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Logger
|
||||
'''
|
||||
|
||||
## Import modules
|
||||
from sys import argv
|
||||
from sys import stdout
|
||||
from sys import stderr
|
||||
import os.path
|
||||
from os import remove
|
||||
from logging import getLogger
|
||||
from logging import Formatter
|
||||
from logging import StreamHandler
|
||||
from logging import FileHandler
|
||||
from traceback import extract_stack
|
||||
|
||||
from Logger.ToolError import FatalError
|
||||
from Logger.ToolError import WARNING_AS_ERROR
|
||||
from Logger.ToolError import gERROR_MESSAGE
|
||||
from Logger.ToolError import UNKNOWN_ERROR
|
||||
from Library import GlobalData
|
||||
|
||||
#
|
||||
# Log level constants
|
||||
#
|
||||
DEBUG_0 = 1
|
||||
DEBUG_1 = 2
|
||||
DEBUG_2 = 3
|
||||
DEBUG_3 = 4
|
||||
DEBUG_4 = 5
|
||||
DEBUG_5 = 6
|
||||
DEBUG_6 = 7
|
||||
DEBUG_7 = 8
|
||||
DEBUG_8 = 9
|
||||
DEBUG_9 = 10
|
||||
VERBOSE = 15
|
||||
INFO = 20
|
||||
WARN = 30
|
||||
QUIET = 40
|
||||
QUIET_1 = 41
|
||||
ERROR = 50
|
||||
SILENT = 60
|
||||
|
||||
IS_RAISE_ERROR = True
|
||||
SUPRESS_ERROR = False
|
||||
|
||||
#
|
||||
# Tool name
|
||||
#
|
||||
_TOOL_NAME = os.path.basename(argv[0])
|
||||
#
|
||||
# For validation purpose
|
||||
#
|
||||
_LOG_LEVELS = [DEBUG_0, DEBUG_1, DEBUG_2, DEBUG_3, DEBUG_4, DEBUG_5, DEBUG_6, \
|
||||
DEBUG_7, DEBUG_8, DEBUG_9, VERBOSE, WARN, INFO, ERROR, QUIET, \
|
||||
QUIET_1, SILENT]
|
||||
#
|
||||
# For DEBUG level (All DEBUG_0~9 are applicable)
|
||||
#
|
||||
_DEBUG_LOGGER = getLogger("tool_debug")
|
||||
_DEBUG_FORMATTER = Formatter("[%(asctime)s.%(msecs)d]: %(message)s", \
|
||||
datefmt="%H:%M:%S")
|
||||
#
|
||||
# For VERBOSE, INFO, WARN level
|
||||
#
|
||||
_INFO_LOGGER = getLogger("tool_info")
|
||||
_INFO_FORMATTER = Formatter("%(message)s")
|
||||
#
|
||||
# For ERROR level
|
||||
#
|
||||
_ERROR_LOGGER = getLogger("tool_error")
|
||||
_ERROR_FORMATTER = Formatter("%(message)s")
|
||||
|
||||
#
|
||||
# String templates for ERROR/WARN/DEBUG log message
|
||||
#
|
||||
_ERROR_MESSAGE_TEMPLATE = \
|
||||
('\n\n%(tool)s...\n%(file)s(%(line)s): error %(errorcode)04X: %(msg)s\n\t%(extra)s')
|
||||
|
||||
__ERROR_MESSAGE_TEMPLATE_WITHOUT_FILE = \
|
||||
'\n\n%(tool)s...\n : error %(errorcode)04X: %(msg)s\n\t%(extra)s'
|
||||
|
||||
_WARNING_MESSAGE_TEMPLATE = '%(tool)s...\n%(file)s(%(line)s): warning: %(msg)s'
|
||||
_WARNING_MESSAGE_TEMPLATE_WITHOUT_FILE = '%(tool)s: : warning: %(msg)s'
|
||||
_DEBUG_MESSAGE_TEMPLATE = '%(file)s(%(line)s): debug: \n %(msg)s'
|
||||
|
||||
|
||||
#
|
||||
# Log INFO message
|
||||
#
|
||||
#Info = _INFO_LOGGER.info
|
||||
|
||||
def Info(msg, *args, **kwargs):
|
||||
_INFO_LOGGER.info(msg, *args, **kwargs)
|
||||
|
||||
#
|
||||
# Log information which should be always put out
|
||||
#
|
||||
def Quiet(msg, *args, **kwargs):
|
||||
_ERROR_LOGGER.error(msg, *args, **kwargs)
|
||||
|
||||
## Log debug message
|
||||
#
|
||||
# @param Level DEBUG level (DEBUG0~9)
|
||||
# @param Message Debug information
|
||||
# @param ExtraData More information associated with "Message"
|
||||
#
|
||||
def Debug(Level, Message, ExtraData=None):
|
||||
if _DEBUG_LOGGER.level > Level:
|
||||
return
|
||||
if Level > DEBUG_9:
|
||||
return
|
||||
#
|
||||
# Find out the caller method information
|
||||
#
|
||||
CallerStack = extract_stack()[-2]
|
||||
TemplateDict = {
|
||||
"file" : CallerStack[0],
|
||||
"line" : CallerStack[1],
|
||||
"msg" : Message,
|
||||
}
|
||||
|
||||
if ExtraData != None:
|
||||
LogText = _DEBUG_MESSAGE_TEMPLATE % TemplateDict + "\n %s" % ExtraData
|
||||
else:
|
||||
LogText = _DEBUG_MESSAGE_TEMPLATE % TemplateDict
|
||||
|
||||
_DEBUG_LOGGER.log(Level, LogText)
|
||||
|
||||
## Log verbose message
|
||||
#
|
||||
# @param Message Verbose information
|
||||
#
|
||||
def Verbose(Message):
|
||||
return _INFO_LOGGER.log(VERBOSE, Message)
|
||||
|
||||
## Log warning message
|
||||
#
|
||||
# Warning messages are those which might be wrong but won't fail the tool.
|
||||
#
|
||||
# @param ToolName The name of the tool. If not given, the name of caller
|
||||
# method will be used.
|
||||
# @param Message Warning information
|
||||
# @param File The name of file which caused the warning.
|
||||
# @param Line The line number in the "File" which caused the warning.
|
||||
# @param ExtraData More information associated with "Message"
|
||||
#
|
||||
def Warn(ToolName, Message, File=None, Line=None, ExtraData=None):
|
||||
if _INFO_LOGGER.level > WARN:
|
||||
return
|
||||
#
|
||||
# if no tool name given, use caller's source file name as tool name
|
||||
#
|
||||
if ToolName == None or ToolName == "":
|
||||
ToolName = os.path.basename(extract_stack()[-2][0])
|
||||
|
||||
if Line == None:
|
||||
Line = "..."
|
||||
else:
|
||||
Line = "%d" % Line
|
||||
|
||||
TemplateDict = {
|
||||
"tool" : ToolName,
|
||||
"file" : File,
|
||||
"line" : Line,
|
||||
"msg" : Message,
|
||||
}
|
||||
|
||||
if File != None:
|
||||
LogText = _WARNING_MESSAGE_TEMPLATE % TemplateDict
|
||||
else:
|
||||
LogText = _WARNING_MESSAGE_TEMPLATE_WITHOUT_FILE % TemplateDict
|
||||
|
||||
if ExtraData != None:
|
||||
LogText += "\n %s" % ExtraData
|
||||
|
||||
_INFO_LOGGER.log(WARN, LogText)
|
||||
#
|
||||
# Raise an execption if indicated
|
||||
#
|
||||
if GlobalData.gWARNING_AS_ERROR == True:
|
||||
raise FatalError(WARNING_AS_ERROR)
|
||||
|
||||
## Log ERROR message
|
||||
#
|
||||
# Once an error messages is logged, the tool's execution will be broken by
|
||||
# raising an execption. If you don't want to break the execution later, you
|
||||
# can give "RaiseError" with "False" value.
|
||||
#
|
||||
# @param ToolName The name of the tool. If not given, the name of caller
|
||||
# method will be used.
|
||||
# @param ErrorCode The error code
|
||||
# @param Message Warning information
|
||||
# @param File The name of file which caused the error.
|
||||
# @param Line The line number in the "File" which caused the warning.
|
||||
# @param ExtraData More information associated with "Message"
|
||||
# @param RaiseError Raise an exception to break the tool's executuion if
|
||||
# it's True. This is the default behavior.
|
||||
#
|
||||
def Error(ToolName, ErrorCode, Message=None, File=None, Line=None, \
|
||||
ExtraData=None, RaiseError=IS_RAISE_ERROR):
|
||||
if ToolName:
|
||||
pass
|
||||
if Line == None:
|
||||
Line = "..."
|
||||
else:
|
||||
Line = "%d" % Line
|
||||
|
||||
if Message == None:
|
||||
if ErrorCode in gERROR_MESSAGE:
|
||||
Message = gERROR_MESSAGE[ErrorCode]
|
||||
else:
|
||||
Message = gERROR_MESSAGE[UNKNOWN_ERROR]
|
||||
|
||||
if ExtraData == None:
|
||||
ExtraData = ""
|
||||
|
||||
TemplateDict = {
|
||||
"tool" : _TOOL_NAME,
|
||||
"file" : File,
|
||||
"line" : Line,
|
||||
"errorcode" : ErrorCode,
|
||||
"msg" : Message,
|
||||
"extra" : ExtraData
|
||||
}
|
||||
|
||||
if File != None:
|
||||
LogText = _ERROR_MESSAGE_TEMPLATE % TemplateDict
|
||||
else:
|
||||
LogText = __ERROR_MESSAGE_TEMPLATE_WITHOUT_FILE % TemplateDict
|
||||
|
||||
if not SUPRESS_ERROR:
|
||||
_ERROR_LOGGER.log(ERROR, LogText)
|
||||
if RaiseError:
|
||||
raise FatalError(ErrorCode)
|
||||
|
||||
|
||||
## Initialize log system
|
||||
#
|
||||
def Initialize():
|
||||
#
|
||||
# Since we use different format to log different levels of message into
|
||||
# different place (stdout or stderr), we have to use different "Logger"
|
||||
# objects to do this.
|
||||
#
|
||||
# For DEBUG level (All DEBUG_0~9 are applicable)
|
||||
_DEBUG_LOGGER.setLevel(INFO)
|
||||
_DebugChannel = StreamHandler(stdout)
|
||||
_DebugChannel.setFormatter(_DEBUG_FORMATTER)
|
||||
_DEBUG_LOGGER.addHandler(_DebugChannel)
|
||||
#
|
||||
# For VERBOSE, INFO, WARN level
|
||||
#
|
||||
_INFO_LOGGER.setLevel(INFO)
|
||||
_InfoChannel = StreamHandler(stdout)
|
||||
_InfoChannel.setFormatter(_INFO_FORMATTER)
|
||||
_INFO_LOGGER.addHandler(_InfoChannel)
|
||||
#
|
||||
# For ERROR level
|
||||
#
|
||||
_ERROR_LOGGER.setLevel(INFO)
|
||||
_ErrorCh = StreamHandler(stderr)
|
||||
_ErrorCh.setFormatter(_ERROR_FORMATTER)
|
||||
_ERROR_LOGGER.addHandler(_ErrorCh)
|
||||
|
||||
|
||||
## Set log level
|
||||
#
|
||||
# @param Level One of log level in _LogLevel
|
||||
#
|
||||
def SetLevel(Level):
|
||||
if Level not in _LOG_LEVELS:
|
||||
Info("Not supported log level (%d). Use default level instead." % \
|
||||
Level)
|
||||
Level = INFO
|
||||
_DEBUG_LOGGER.setLevel(Level)
|
||||
_INFO_LOGGER.setLevel(Level)
|
||||
_ERROR_LOGGER.setLevel(Level)
|
||||
|
||||
## Get current log level
|
||||
#
|
||||
def GetLevel():
|
||||
return _INFO_LOGGER.getEffectiveLevel()
|
||||
|
||||
## Raise up warning as error
|
||||
#
|
||||
def SetWarningAsError():
|
||||
GlobalData.gWARNING_AS_ERROR = True
|
||||
|
||||
## Specify a file to store the log message as well as put on console
|
||||
#
|
||||
# @param LogFile The file path used to store the log message
|
||||
#
|
||||
def SetLogFile(LogFile):
|
||||
if os.path.exists(LogFile):
|
||||
remove(LogFile)
|
||||
|
||||
_Ch = FileHandler(LogFile)
|
||||
_Ch.setFormatter(_DEBUG_FORMATTER)
|
||||
_DEBUG_LOGGER.addHandler(_Ch)
|
||||
|
||||
_Ch = FileHandler(LogFile)
|
||||
_Ch.setFormatter(_INFO_FORMATTER)
|
||||
_INFO_LOGGER.addHandler(_Ch)
|
||||
|
||||
_Ch = FileHandler(LogFile)
|
||||
_Ch.setFormatter(_ERROR_FORMATTER)
|
||||
_ERROR_LOGGER.addHandler(_Ch)
|
||||
|
||||
|
||||
|
||||
|
@@ -1,177 +1,177 @@
|
||||
## @file
|
||||
# Standardized Error Hanlding infrastructures.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
ToolError
|
||||
'''
|
||||
|
||||
import Logger.StringTable as ST
|
||||
|
||||
FILE_OPEN_FAILURE = 1
|
||||
FILE_WRITE_FAILURE = 2
|
||||
FILE_PARSE_FAILURE = 3
|
||||
FILE_READ_FAILURE = 4
|
||||
FILE_CREATE_FAILURE = 5
|
||||
FILE_CHECKSUM_FAILURE = 6
|
||||
FILE_COMPRESS_FAILURE = 7
|
||||
FILE_DECOMPRESS_FAILURE = 8
|
||||
FILE_MOVE_FAILURE = 9
|
||||
FILE_DELETE_FAILURE = 10
|
||||
FILE_COPY_FAILURE = 11
|
||||
FILE_POSITIONING_FAILURE = 12
|
||||
FILE_ALREADY_EXIST = 13
|
||||
FILE_NOT_FOUND = 14
|
||||
FILE_TYPE_MISMATCH = 15
|
||||
FILE_CASE_MISMATCH = 16
|
||||
FILE_DUPLICATED = 17
|
||||
FILE_UNKNOWN_ERROR = 0x0FFF
|
||||
|
||||
OPTION_UNKNOWN = 0x1000
|
||||
OPTION_MISSING = 0x1001
|
||||
OPTION_CONFLICT = 0x1002
|
||||
OPTION_VALUE_INVALID = 0x1003
|
||||
OPTION_DEPRECATED = 0x1004
|
||||
OPTION_NOT_SUPPORTED = 0x1005
|
||||
OPTION_UNKNOWN_ERROR = 0x1FFF
|
||||
|
||||
PARAMETER_INVALID = 0x2000
|
||||
PARAMETER_MISSING = 0x2001
|
||||
PARAMETER_UNKNOWN_ERROR = 0x2FFF
|
||||
|
||||
FORMAT_INVALID = 0x3000
|
||||
FORMAT_NOT_SUPPORTED = 0x3001
|
||||
FORMAT_UNKNOWN = 0x3002
|
||||
FORMAT_UNKNOWN_ERROR = 0x3FFF
|
||||
|
||||
RESOURCE_NOT_AVAILABLE = 0x4000
|
||||
RESOURCE_ALLOCATE_FAILURE = 0x4001
|
||||
RESOURCE_FULL = 0x4002
|
||||
RESOURCE_OVERFLOW = 0x4003
|
||||
RESOURCE_UNDERRUN = 0x4004
|
||||
RESOURCE_UNKNOWN_ERROR = 0x4FFF
|
||||
|
||||
ATTRIBUTE_NOT_AVAILABLE = 0x5000
|
||||
ATTRIBUTE_GET_FAILURE = 0x5001
|
||||
ATTRIBUTE_SET_FAILURE = 0x5002
|
||||
ATTRIBUTE_UPDATE_FAILURE = 0x5003
|
||||
ATTRIBUTE_ACCESS_DENIED = 0x5004
|
||||
ATTRIBUTE_RETRIEVE_FAILURE = 0x5005
|
||||
ATTRIBUTE_UNKNOWN_ERROR = 0x5FFF
|
||||
ATTRIBUTE_RETRIEVE_FAILURE = 0x5F00
|
||||
|
||||
IO_NOT_READY = 0x6000
|
||||
IO_BUSY = 0x6001
|
||||
IO_TIMEOUT = 0x6002
|
||||
IO_UNKNOWN_ERROR = 0x6FFF
|
||||
|
||||
COMMAND_FAILURE = 0x7000
|
||||
|
||||
CODE_ERROR = 0xC0DE
|
||||
|
||||
AUTOGEN_ERROR = 0xF000
|
||||
PARSER_ERROR = 0xF001
|
||||
BUILD_ERROR = 0xF002
|
||||
GENFDS_ERROR = 0xF003
|
||||
ECC_ERROR = 0xF004
|
||||
EOT_ERROR = 0xF005
|
||||
DDC_ERROR = 0xF009
|
||||
WARNING_AS_ERROR = 0xF006
|
||||
MIGRATION_ERROR = 0xF010
|
||||
EDK1_INF_ERROR = 0xF011
|
||||
ABORT_ERROR = 0xFFFE
|
||||
UNKNOWN_ERROR = 0xFFFF
|
||||
|
||||
UPT_ALREADY_INSTALLED_ERROR = 0xD000
|
||||
UPT_ENVIRON_MISSING_ERROR = 0xD001
|
||||
UPT_REPKG_ERROR = 0xD002
|
||||
UPT_ALREADY_RUNNING_ERROR = 0xD003
|
||||
UPT_MUL_DEC_ERROR = 0xD004
|
||||
UPT_DB_UPDATE_ERROR = 0xD005
|
||||
UPT_INI_PARSE_ERROR = 0xE000
|
||||
|
||||
## Error message of each error code
|
||||
#
|
||||
gERROR_MESSAGE = {
|
||||
FILE_NOT_FOUND : ST.ERR_FILE_NOT_FOUND,
|
||||
FILE_OPEN_FAILURE : ST.ERR_FILE_OPEN_FAILURE,
|
||||
FILE_WRITE_FAILURE : ST.ERR_FILE_WRITE_FAILURE,
|
||||
FILE_PARSE_FAILURE : ST.ERR_FILE_PARSE_FAILURE,
|
||||
FILE_READ_FAILURE : ST.ERR_FILE_READ_FAILURE,
|
||||
FILE_CREATE_FAILURE : ST.ERR_FILE_CREATE_FAILURE,
|
||||
FILE_CHECKSUM_FAILURE : ST.ERR_FILE_CHECKSUM_FAILURE,
|
||||
FILE_COMPRESS_FAILURE : ST.ERR_FILE_COMPRESS_FAILURE,
|
||||
FILE_DECOMPRESS_FAILURE : ST.ERR_FILE_DECOMPRESS_FAILURE,
|
||||
FILE_MOVE_FAILURE : ST.ERR_FILE_MOVE_FAILURE,
|
||||
FILE_DELETE_FAILURE : ST.ERR_FILE_DELETE_FAILURE,
|
||||
FILE_COPY_FAILURE : ST.ERR_FILE_COPY_FAILURE,
|
||||
FILE_POSITIONING_FAILURE: ST.ERR_FILE_POSITIONING_FAILURE,
|
||||
FILE_ALREADY_EXIST : ST.ERR_FILE_ALREADY_EXIST,
|
||||
FILE_TYPE_MISMATCH : ST.ERR_FILE_TYPE_MISMATCH ,
|
||||
FILE_CASE_MISMATCH : ST.ERR_FILE_CASE_MISMATCH,
|
||||
FILE_DUPLICATED : ST.ERR_FILE_DUPLICATED,
|
||||
FILE_UNKNOWN_ERROR : ST.ERR_FILE_UNKNOWN_ERROR,
|
||||
|
||||
OPTION_UNKNOWN : ST.ERR_OPTION_UNKNOWN,
|
||||
OPTION_MISSING : ST.ERR_OPTION_MISSING,
|
||||
OPTION_CONFLICT : ST.ERR_OPTION_CONFLICT,
|
||||
OPTION_VALUE_INVALID : ST.ERR_OPTION_VALUE_INVALID,
|
||||
OPTION_DEPRECATED : ST.ERR_OPTION_DEPRECATED,
|
||||
OPTION_NOT_SUPPORTED : ST.ERR_OPTION_NOT_SUPPORTED,
|
||||
OPTION_UNKNOWN_ERROR : ST.ERR_OPTION_UNKNOWN_ERROR,
|
||||
|
||||
PARAMETER_INVALID : ST.ERR_PARAMETER_INVALID,
|
||||
PARAMETER_MISSING : ST.ERR_PARAMETER_MISSING,
|
||||
PARAMETER_UNKNOWN_ERROR : ST.ERR_PARAMETER_UNKNOWN_ERROR,
|
||||
|
||||
FORMAT_INVALID : ST.ERR_FORMAT_INVALID,
|
||||
FORMAT_NOT_SUPPORTED : ST.ERR_FORMAT_NOT_SUPPORTED,
|
||||
FORMAT_UNKNOWN : ST.ERR_FORMAT_UNKNOWN,
|
||||
FORMAT_UNKNOWN_ERROR : ST.ERR_FORMAT_UNKNOWN_ERROR,
|
||||
|
||||
RESOURCE_NOT_AVAILABLE : ST.ERR_RESOURCE_NOT_AVAILABLE,
|
||||
RESOURCE_ALLOCATE_FAILURE : ST.ERR_RESOURCE_ALLOCATE_FAILURE,
|
||||
RESOURCE_FULL : ST.ERR_RESOURCE_FULL,
|
||||
RESOURCE_OVERFLOW : ST.ERR_RESOURCE_OVERFLOW,
|
||||
RESOURCE_UNDERRUN : ST.ERR_RESOURCE_UNDERRUN,
|
||||
RESOURCE_UNKNOWN_ERROR : ST.ERR_RESOURCE_UNKNOWN_ERROR,
|
||||
|
||||
ATTRIBUTE_NOT_AVAILABLE : ST.ERR_ATTRIBUTE_NOT_AVAILABLE,
|
||||
ATTRIBUTE_RETRIEVE_FAILURE : ST.ERR_ATTRIBUTE_RETRIEVE_FAILURE,
|
||||
ATTRIBUTE_SET_FAILURE : ST.ERR_ATTRIBUTE_SET_FAILURE,
|
||||
ATTRIBUTE_UPDATE_FAILURE: ST.ERR_ATTRIBUTE_UPDATE_FAILURE,
|
||||
ATTRIBUTE_ACCESS_DENIED : ST.ERR_ATTRIBUTE_ACCESS_DENIED,
|
||||
ATTRIBUTE_UNKNOWN_ERROR : ST.ERR_ATTRIBUTE_UNKNOWN_ERROR,
|
||||
|
||||
COMMAND_FAILURE : ST.ERR_COMMAND_FAILURE,
|
||||
|
||||
IO_NOT_READY : ST.ERR_IO_NOT_READY,
|
||||
IO_BUSY : ST.ERR_IO_BUSY,
|
||||
IO_TIMEOUT : ST.ERR_IO_TIMEOUT,
|
||||
IO_UNKNOWN_ERROR : ST.ERR_IO_UNKNOWN_ERROR,
|
||||
|
||||
UNKNOWN_ERROR : ST.ERR_UNKNOWN_ERROR,
|
||||
|
||||
UPT_ALREADY_INSTALLED_ERROR : ST.ERR_UPT_ALREADY_INSTALLED_ERROR,
|
||||
UPT_ENVIRON_MISSING_ERROR : ST.ERR_UPT_ENVIRON_MISSING_ERROR,
|
||||
UPT_REPKG_ERROR : ST.ERR_UPT_REPKG_ERROR,
|
||||
UPT_ALREADY_RUNNING_ERROR : ST.ERR_UPT_ALREADY_RUNNING_ERROR,
|
||||
UPT_MUL_DEC_ERROR : ST.ERR_MUL_DEC_ERROR,
|
||||
UPT_INI_PARSE_ERROR : ST.ERR_UPT_INI_PARSE_ERROR,
|
||||
}
|
||||
|
||||
## Exception indicating a fatal error
|
||||
#
|
||||
class FatalError(Exception):
|
||||
pass
|
||||
|
||||
## @file
|
||||
# Standardized Error Hanlding infrastructures.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
ToolError
|
||||
'''
|
||||
|
||||
import Logger.StringTable as ST
|
||||
|
||||
FILE_OPEN_FAILURE = 1
|
||||
FILE_WRITE_FAILURE = 2
|
||||
FILE_PARSE_FAILURE = 3
|
||||
FILE_READ_FAILURE = 4
|
||||
FILE_CREATE_FAILURE = 5
|
||||
FILE_CHECKSUM_FAILURE = 6
|
||||
FILE_COMPRESS_FAILURE = 7
|
||||
FILE_DECOMPRESS_FAILURE = 8
|
||||
FILE_MOVE_FAILURE = 9
|
||||
FILE_DELETE_FAILURE = 10
|
||||
FILE_COPY_FAILURE = 11
|
||||
FILE_POSITIONING_FAILURE = 12
|
||||
FILE_ALREADY_EXIST = 13
|
||||
FILE_NOT_FOUND = 14
|
||||
FILE_TYPE_MISMATCH = 15
|
||||
FILE_CASE_MISMATCH = 16
|
||||
FILE_DUPLICATED = 17
|
||||
FILE_UNKNOWN_ERROR = 0x0FFF
|
||||
|
||||
OPTION_UNKNOWN = 0x1000
|
||||
OPTION_MISSING = 0x1001
|
||||
OPTION_CONFLICT = 0x1002
|
||||
OPTION_VALUE_INVALID = 0x1003
|
||||
OPTION_DEPRECATED = 0x1004
|
||||
OPTION_NOT_SUPPORTED = 0x1005
|
||||
OPTION_UNKNOWN_ERROR = 0x1FFF
|
||||
|
||||
PARAMETER_INVALID = 0x2000
|
||||
PARAMETER_MISSING = 0x2001
|
||||
PARAMETER_UNKNOWN_ERROR = 0x2FFF
|
||||
|
||||
FORMAT_INVALID = 0x3000
|
||||
FORMAT_NOT_SUPPORTED = 0x3001
|
||||
FORMAT_UNKNOWN = 0x3002
|
||||
FORMAT_UNKNOWN_ERROR = 0x3FFF
|
||||
|
||||
RESOURCE_NOT_AVAILABLE = 0x4000
|
||||
RESOURCE_ALLOCATE_FAILURE = 0x4001
|
||||
RESOURCE_FULL = 0x4002
|
||||
RESOURCE_OVERFLOW = 0x4003
|
||||
RESOURCE_UNDERRUN = 0x4004
|
||||
RESOURCE_UNKNOWN_ERROR = 0x4FFF
|
||||
|
||||
ATTRIBUTE_NOT_AVAILABLE = 0x5000
|
||||
ATTRIBUTE_GET_FAILURE = 0x5001
|
||||
ATTRIBUTE_SET_FAILURE = 0x5002
|
||||
ATTRIBUTE_UPDATE_FAILURE = 0x5003
|
||||
ATTRIBUTE_ACCESS_DENIED = 0x5004
|
||||
ATTRIBUTE_RETRIEVE_FAILURE = 0x5005
|
||||
ATTRIBUTE_UNKNOWN_ERROR = 0x5FFF
|
||||
ATTRIBUTE_RETRIEVE_FAILURE = 0x5F00
|
||||
|
||||
IO_NOT_READY = 0x6000
|
||||
IO_BUSY = 0x6001
|
||||
IO_TIMEOUT = 0x6002
|
||||
IO_UNKNOWN_ERROR = 0x6FFF
|
||||
|
||||
COMMAND_FAILURE = 0x7000
|
||||
|
||||
CODE_ERROR = 0xC0DE
|
||||
|
||||
AUTOGEN_ERROR = 0xF000
|
||||
PARSER_ERROR = 0xF001
|
||||
BUILD_ERROR = 0xF002
|
||||
GENFDS_ERROR = 0xF003
|
||||
ECC_ERROR = 0xF004
|
||||
EOT_ERROR = 0xF005
|
||||
DDC_ERROR = 0xF009
|
||||
WARNING_AS_ERROR = 0xF006
|
||||
MIGRATION_ERROR = 0xF010
|
||||
EDK1_INF_ERROR = 0xF011
|
||||
ABORT_ERROR = 0xFFFE
|
||||
UNKNOWN_ERROR = 0xFFFF
|
||||
|
||||
UPT_ALREADY_INSTALLED_ERROR = 0xD000
|
||||
UPT_ENVIRON_MISSING_ERROR = 0xD001
|
||||
UPT_REPKG_ERROR = 0xD002
|
||||
UPT_ALREADY_RUNNING_ERROR = 0xD003
|
||||
UPT_MUL_DEC_ERROR = 0xD004
|
||||
UPT_DB_UPDATE_ERROR = 0xD005
|
||||
UPT_INI_PARSE_ERROR = 0xE000
|
||||
|
||||
## Error message of each error code
|
||||
#
|
||||
gERROR_MESSAGE = {
|
||||
FILE_NOT_FOUND : ST.ERR_FILE_NOT_FOUND,
|
||||
FILE_OPEN_FAILURE : ST.ERR_FILE_OPEN_FAILURE,
|
||||
FILE_WRITE_FAILURE : ST.ERR_FILE_WRITE_FAILURE,
|
||||
FILE_PARSE_FAILURE : ST.ERR_FILE_PARSE_FAILURE,
|
||||
FILE_READ_FAILURE : ST.ERR_FILE_READ_FAILURE,
|
||||
FILE_CREATE_FAILURE : ST.ERR_FILE_CREATE_FAILURE,
|
||||
FILE_CHECKSUM_FAILURE : ST.ERR_FILE_CHECKSUM_FAILURE,
|
||||
FILE_COMPRESS_FAILURE : ST.ERR_FILE_COMPRESS_FAILURE,
|
||||
FILE_DECOMPRESS_FAILURE : ST.ERR_FILE_DECOMPRESS_FAILURE,
|
||||
FILE_MOVE_FAILURE : ST.ERR_FILE_MOVE_FAILURE,
|
||||
FILE_DELETE_FAILURE : ST.ERR_FILE_DELETE_FAILURE,
|
||||
FILE_COPY_FAILURE : ST.ERR_FILE_COPY_FAILURE,
|
||||
FILE_POSITIONING_FAILURE: ST.ERR_FILE_POSITIONING_FAILURE,
|
||||
FILE_ALREADY_EXIST : ST.ERR_FILE_ALREADY_EXIST,
|
||||
FILE_TYPE_MISMATCH : ST.ERR_FILE_TYPE_MISMATCH ,
|
||||
FILE_CASE_MISMATCH : ST.ERR_FILE_CASE_MISMATCH,
|
||||
FILE_DUPLICATED : ST.ERR_FILE_DUPLICATED,
|
||||
FILE_UNKNOWN_ERROR : ST.ERR_FILE_UNKNOWN_ERROR,
|
||||
|
||||
OPTION_UNKNOWN : ST.ERR_OPTION_UNKNOWN,
|
||||
OPTION_MISSING : ST.ERR_OPTION_MISSING,
|
||||
OPTION_CONFLICT : ST.ERR_OPTION_CONFLICT,
|
||||
OPTION_VALUE_INVALID : ST.ERR_OPTION_VALUE_INVALID,
|
||||
OPTION_DEPRECATED : ST.ERR_OPTION_DEPRECATED,
|
||||
OPTION_NOT_SUPPORTED : ST.ERR_OPTION_NOT_SUPPORTED,
|
||||
OPTION_UNKNOWN_ERROR : ST.ERR_OPTION_UNKNOWN_ERROR,
|
||||
|
||||
PARAMETER_INVALID : ST.ERR_PARAMETER_INVALID,
|
||||
PARAMETER_MISSING : ST.ERR_PARAMETER_MISSING,
|
||||
PARAMETER_UNKNOWN_ERROR : ST.ERR_PARAMETER_UNKNOWN_ERROR,
|
||||
|
||||
FORMAT_INVALID : ST.ERR_FORMAT_INVALID,
|
||||
FORMAT_NOT_SUPPORTED : ST.ERR_FORMAT_NOT_SUPPORTED,
|
||||
FORMAT_UNKNOWN : ST.ERR_FORMAT_UNKNOWN,
|
||||
FORMAT_UNKNOWN_ERROR : ST.ERR_FORMAT_UNKNOWN_ERROR,
|
||||
|
||||
RESOURCE_NOT_AVAILABLE : ST.ERR_RESOURCE_NOT_AVAILABLE,
|
||||
RESOURCE_ALLOCATE_FAILURE : ST.ERR_RESOURCE_ALLOCATE_FAILURE,
|
||||
RESOURCE_FULL : ST.ERR_RESOURCE_FULL,
|
||||
RESOURCE_OVERFLOW : ST.ERR_RESOURCE_OVERFLOW,
|
||||
RESOURCE_UNDERRUN : ST.ERR_RESOURCE_UNDERRUN,
|
||||
RESOURCE_UNKNOWN_ERROR : ST.ERR_RESOURCE_UNKNOWN_ERROR,
|
||||
|
||||
ATTRIBUTE_NOT_AVAILABLE : ST.ERR_ATTRIBUTE_NOT_AVAILABLE,
|
||||
ATTRIBUTE_RETRIEVE_FAILURE : ST.ERR_ATTRIBUTE_RETRIEVE_FAILURE,
|
||||
ATTRIBUTE_SET_FAILURE : ST.ERR_ATTRIBUTE_SET_FAILURE,
|
||||
ATTRIBUTE_UPDATE_FAILURE: ST.ERR_ATTRIBUTE_UPDATE_FAILURE,
|
||||
ATTRIBUTE_ACCESS_DENIED : ST.ERR_ATTRIBUTE_ACCESS_DENIED,
|
||||
ATTRIBUTE_UNKNOWN_ERROR : ST.ERR_ATTRIBUTE_UNKNOWN_ERROR,
|
||||
|
||||
COMMAND_FAILURE : ST.ERR_COMMAND_FAILURE,
|
||||
|
||||
IO_NOT_READY : ST.ERR_IO_NOT_READY,
|
||||
IO_BUSY : ST.ERR_IO_BUSY,
|
||||
IO_TIMEOUT : ST.ERR_IO_TIMEOUT,
|
||||
IO_UNKNOWN_ERROR : ST.ERR_IO_UNKNOWN_ERROR,
|
||||
|
||||
UNKNOWN_ERROR : ST.ERR_UNKNOWN_ERROR,
|
||||
|
||||
UPT_ALREADY_INSTALLED_ERROR : ST.ERR_UPT_ALREADY_INSTALLED_ERROR,
|
||||
UPT_ENVIRON_MISSING_ERROR : ST.ERR_UPT_ENVIRON_MISSING_ERROR,
|
||||
UPT_REPKG_ERROR : ST.ERR_UPT_REPKG_ERROR,
|
||||
UPT_ALREADY_RUNNING_ERROR : ST.ERR_UPT_ALREADY_RUNNING_ERROR,
|
||||
UPT_MUL_DEC_ERROR : ST.ERR_MUL_DEC_ERROR,
|
||||
UPT_INI_PARSE_ERROR : ST.ERR_UPT_INI_PARSE_ERROR,
|
||||
}
|
||||
|
||||
## Exception indicating a fatal error
|
||||
#
|
||||
class FatalError(Exception):
|
||||
pass
|
||||
|
||||
|
@@ -1,20 +1,20 @@
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Xml
|
||||
## @file
|
||||
# Python 'Library' package initialization file.
|
||||
#
|
||||
# This file is required to make Python interpreter treat the directory
|
||||
# as containing package.
|
||||
#
|
||||
# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
|
||||
#
|
||||
# This program and the accompanying materials are licensed and made available
|
||||
# under the terms and conditions of the BSD License which accompanies this
|
||||
# distribution. The full text of the license may be found at
|
||||
# http://opensource.org/licenses/bsd-license.php
|
||||
#
|
||||
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
#
|
||||
|
||||
'''
|
||||
Xml
|
||||
'''
|
Reference in New Issue
Block a user