X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FTable%2FTableReport.py;h=c4a622953ece8e00be0c1e28ab8ab42efb6c6a63;hb=ac107416484b74e5d412f7b48268761f9ba95afe;hp=777a479156d0ec338b1538d7e9d5fb075a45cb23;hpb=52302d4dee589a5df43a464420c9fe68ba83937d;p=mirror_edk2.git diff --git a/BaseTools/Source/Python/Table/TableReport.py b/BaseTools/Source/Python/Table/TableReport.py index 777a479156..c4a622953e 100644 --- a/BaseTools/Source/Python/Table/TableReport.py +++ b/BaseTools/Source/Python/Table/TableReport.py @@ -1,8 +1,8 @@ ## @file # This file is used to create/update/query/erase table for ECC reports # -# Copyright (c) 2008 - 2010, Intel Corporation -# All rights reserved. This program and the accompanying materials +# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.
+# 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 @@ -14,17 +14,19 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger -import os, time -from Table import Table -from Common.String import ConvertToSqlString2 +import Common.LongFilePathOs as os, time +from .Table import Table +from Common.StringUtils import ConvertToSqlString2 import EccToolError as EccToolError import EccGlobalData as EccGlobalData +from Common.LongFilePathSupport import OpenLongFilePath as open ## TableReport # # This class defined a table used for data model -# +# # @param object: Inherited from object class # # @@ -32,7 +34,7 @@ class TableReport(Table): def __init__(self, Cursor): Table.__init__(self, Cursor) self.Table = 'Report' - + ## Create table # # Create table report @@ -67,30 +69,37 @@ class TableReport(Table): # @param Enabled: If this error enabled # @param Corrected: if this error corrected # - def Insert(self, ErrorID, OtherMsg = '', BelongsToTable = '', BelongsToItem = -1, Enabled = 0, Corrected = -1): + def Insert(self, ErrorID, OtherMsg='', BelongsToTable='', BelongsToItem= -1, Enabled=0, Corrected= -1): self.ID = self.ID + 1 SqlCommand = """insert into %s values(%s, %s, '%s', '%s', %s, %s, %s)""" \ % (self.Table, self.ID, ErrorID, ConvertToSqlString2(OtherMsg), BelongsToTable, BelongsToItem, Enabled, Corrected) Table.Insert(self, SqlCommand) - + return self.ID - + ## Query table # - # @retval: A recordSet of all found records + # @retval: A recordSet of all found records # def Query(self): SqlCommand = """select ID, ErrorID, OtherMsg, BelongsToTable, BelongsToItem, Corrected from %s where Enabled > -1 order by ErrorID, BelongsToItem""" % (self.Table) return self.Exec(SqlCommand) + ## Update table + # + def UpdateBelongsToItemByFile(self, ItemID=-1, File=""): + SqlCommand = """update Report set BelongsToItem=%s where BelongsToTable='File' and BelongsToItem=-2 + and OtherMsg like '%%%s%%'""" % (ItemID, File) + return self.Exec(SqlCommand) + ## Convert to CSV # # Get all enabled records from table report and save them to a .csv file # # @param Filename: To filename to save the report content # - def ToCSV(self, Filename = 'Report.csv'): + def ToCSV(self, Filename='Report.csv'): try: File = open(Filename, 'w+') File.write("""No, Error Code, Error Message, File, LineNo, Other Error Message\n""") @@ -105,7 +114,7 @@ class TableReport(Table): IsCorrected = Record[5] SqlCommand = '' if BelongsToTable == 'File': - SqlCommand = """select 0, FullPath from %s where ID = %s + SqlCommand = """select 1, FullPath from %s where ID = %s """ % (BelongsToTable, BelongsToItem) else: SqlCommand = """select A.StartLine, B.FullPath from %s as A, File as B @@ -115,7 +124,7 @@ class TableReport(Table): if NewRecord != []: File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % (Index, ErrorID, EccToolError.gEccErrorMessage[ErrorID], NewRecord[0][1], NewRecord[0][0], OtherMsg)) EdkLogger.quiet("%s(%s): [%s]%s %s" % (NewRecord[0][1], NewRecord[0][0], ErrorID, EccToolError.gEccErrorMessage[ErrorID], OtherMsg)) - + File.close() except IOError: NewFilename = 'Report_' + time.strftime("%Y%m%d_%H%M%S.csv", time.localtime())