2014-08-26 07:58:02 +02:00
|
|
|
## @file
|
|
|
|
# Inventory workspace's distribution package information.
|
|
|
|
#
|
2018-07-05 11:40:04 +02:00
|
|
|
# Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>
|
2014-08-26 07:58:02 +02:00
|
|
|
#
|
2018-07-05 11:40:04 +02:00
|
|
|
# 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
|
2014-08-26 07:58:02 +02:00
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
"""
|
|
|
|
Inventory workspace's distribution package information.
|
|
|
|
"""
|
|
|
|
##
|
|
|
|
# Import Modules
|
|
|
|
#
|
|
|
|
from sys import platform
|
|
|
|
from traceback import format_exc
|
|
|
|
from platform import python_version
|
|
|
|
|
|
|
|
from Logger import StringTable as ST
|
|
|
|
from Logger.ToolError import FatalError
|
|
|
|
from Logger.ToolError import ABORT_ERROR
|
|
|
|
from Logger.ToolError import CODE_ERROR
|
|
|
|
import Logger.Log as Logger
|
|
|
|
|
|
|
|
from Library import GlobalData
|
|
|
|
|
|
|
|
## InventoryDistInstalled
|
|
|
|
#
|
|
|
|
# This method retrieves the installed distribution information from the internal UPT database
|
|
|
|
#
|
|
|
|
# @param DataBase: the UPT database
|
|
|
|
#
|
|
|
|
def InventoryDistInstalled(DataBase):
|
|
|
|
DistInstalled = DataBase.InventoryDistInstalled()
|
2018-07-05 11:40:04 +02:00
|
|
|
|
2014-08-26 07:58:02 +02:00
|
|
|
#
|
|
|
|
# find the max length for each item
|
|
|
|
#
|
|
|
|
DpNameStr = "DpName"
|
|
|
|
DpGuidStr = "DpGuid"
|
|
|
|
DpVerStr = "DpVer"
|
|
|
|
DpOriginalNameStr = "DpOriginalName"
|
|
|
|
MaxGuidlen = len(DpGuidStr)
|
|
|
|
MaxVerlen = len(DpVerStr)
|
2018-07-05 11:40:04 +02:00
|
|
|
MaxDpAliasFileNameLen = len(DpNameStr)
|
2014-08-26 07:58:02 +02:00
|
|
|
MaxDpOrigFileNamelen = len(DpOriginalNameStr)
|
2018-07-05 11:40:04 +02:00
|
|
|
|
2014-08-26 07:58:02 +02:00
|
|
|
for (DpGuid, DpVersion, DpOriginalName, DpAliasFileName) in DistInstalled:
|
|
|
|
MaxGuidlen = max(MaxGuidlen, len(DpGuid))
|
|
|
|
MaxVerlen = max(MaxVerlen, len(DpVersion))
|
|
|
|
MaxDpAliasFileNameLen = max(MaxDpAliasFileNameLen, len(DpAliasFileName))
|
|
|
|
MaxDpOrigFileNamelen = max(MaxDpOrigFileNamelen, len(DpOriginalName))
|
|
|
|
|
|
|
|
OutMsgFmt = "%-*s\t%-*s\t%-*s\t%-s"
|
2018-07-05 11:40:04 +02:00
|
|
|
OutMsg = OutMsgFmt % (MaxDpAliasFileNameLen,
|
|
|
|
DpNameStr,
|
|
|
|
MaxGuidlen,
|
|
|
|
DpGuidStr,
|
|
|
|
MaxVerlen,
|
|
|
|
DpVerStr,
|
2014-08-26 07:58:02 +02:00
|
|
|
DpOriginalNameStr)
|
|
|
|
Logger.Info(OutMsg)
|
2018-07-05 11:40:04 +02:00
|
|
|
|
2014-08-26 07:58:02 +02:00
|
|
|
for (DpGuid, DpVersion, DpFileName, DpAliasFileName) in DistInstalled:
|
2018-07-05 11:40:04 +02:00
|
|
|
OutMsg = OutMsgFmt % (MaxDpAliasFileNameLen,
|
|
|
|
DpAliasFileName,
|
|
|
|
MaxGuidlen,
|
|
|
|
DpGuid,
|
|
|
|
MaxVerlen,
|
|
|
|
DpVersion,
|
2014-08-26 07:58:02 +02:00
|
|
|
DpFileName)
|
|
|
|
Logger.Info(OutMsg)
|
|
|
|
|
|
|
|
## Tool entrance method
|
|
|
|
#
|
|
|
|
# This method mainly dispatch specific methods per the command line options.
|
|
|
|
# If no error found, return zero value so the caller of this tool can know
|
|
|
|
# if it's executed successfully or not.
|
|
|
|
#
|
|
|
|
# @param Options: command Options
|
|
|
|
#
|
|
|
|
def Main(Options = None):
|
|
|
|
if Options:
|
|
|
|
pass
|
|
|
|
|
|
|
|
try:
|
|
|
|
DataBase = GlobalData.gDB
|
2018-07-05 11:40:04 +02:00
|
|
|
InventoryDistInstalled(DataBase)
|
|
|
|
ReturnCode = 0
|
2018-06-25 12:31:25 +02:00
|
|
|
except FatalError as XExcept:
|
2014-08-26 07:58:02 +02:00
|
|
|
ReturnCode = XExcept.args[0]
|
|
|
|
if Logger.GetLevel() <= Logger.DEBUG_9:
|
|
|
|
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
|
2018-07-05 11:40:04 +02:00
|
|
|
except KeyboardInterrupt:
|
2014-08-26 07:58:02 +02:00
|
|
|
ReturnCode = ABORT_ERROR
|
|
|
|
if Logger.GetLevel() <= Logger.DEBUG_9:
|
|
|
|
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
|
|
|
|
except:
|
|
|
|
ReturnCode = CODE_ERROR
|
|
|
|
Logger.Error("\nInventoryWs",
|
|
|
|
CODE_ERROR,
|
|
|
|
ST.ERR_UNKNOWN_FATAL_INVENTORYWS_ERR,
|
|
|
|
ExtraData=ST.MSG_SEARCH_FOR_HELP,
|
|
|
|
RaiseError=False
|
|
|
|
)
|
|
|
|
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(),
|
|
|
|
platform) + format_exc())
|
|
|
|
|
|
|
|
if ReturnCode == 0:
|
|
|
|
Logger.Quiet(ST.MSG_FINISH)
|
2018-07-05 11:40:04 +02:00
|
|
|
|
|
|
|
return ReturnCode
|