]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Table/TableReport.py
BaseTools: Use absolute import in Table
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableReport.py
index 777a479156d0ec338b1538d7e9d5fb075a45cb23..c4a622953ece8e00be0c1e28ab8ab42efb6c6a63 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # This file is used to create/update/query/erase table for ECC reports\r
 #\r
-# Copyright (c) 2008 - 2010, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
 ##\r
 # Import Modules\r
 #\r
+from __future__ import absolute_import\r
 import Common.EdkLogger as EdkLogger\r
-import os, time\r
-from Table import Table\r
-from Common.String import ConvertToSqlString2\r
+import Common.LongFilePathOs as os, time\r
+from .Table import Table\r
+from Common.StringUtils import ConvertToSqlString2\r
 import EccToolError as EccToolError\r
 import EccGlobalData as EccGlobalData\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
 \r
 ## TableReport\r
 #\r
 # This class defined a table used for data model\r
-# \r
+#\r
 # @param object:       Inherited from object class\r
 #\r
 #\r
@@ -32,7 +34,7 @@ class TableReport(Table):
     def __init__(self, Cursor):\r
         Table.__init__(self, Cursor)\r
         self.Table = 'Report'\r
-    \r
+\r
     ## Create table\r
     #\r
     # Create table report\r
@@ -67,30 +69,37 @@ class TableReport(Table):
     # @param Enabled:        If this error enabled\r
     # @param Corrected:      if this error corrected\r
     #\r
-    def Insert(self, ErrorID, OtherMsg = '', BelongsToTable = '', BelongsToItem = -1, Enabled = 0, Corrected = -1):\r
+    def Insert(self, ErrorID, OtherMsg='', BelongsToTable='', BelongsToItem= -1, Enabled=0, Corrected= -1):\r
         self.ID = self.ID + 1\r
         SqlCommand = """insert into %s values(%s, %s, '%s', '%s', %s, %s, %s)""" \\r
                      % (self.Table, self.ID, ErrorID, ConvertToSqlString2(OtherMsg), BelongsToTable, BelongsToItem, Enabled, Corrected)\r
         Table.Insert(self, SqlCommand)\r
-        \r
+\r
         return self.ID\r
-    \r
+\r
     ## Query table\r
     #\r
-    # @retval:       A recordSet of all found records \r
+    # @retval:       A recordSet of all found records\r
     #\r
     def Query(self):\r
         SqlCommand = """select ID, ErrorID, OtherMsg, BelongsToTable, BelongsToItem, Corrected from %s\r
                         where Enabled > -1 order by ErrorID, BelongsToItem""" % (self.Table)\r
         return self.Exec(SqlCommand)\r
 \r
+    ## Update table\r
+    #\r
+    def UpdateBelongsToItemByFile(self, ItemID=-1, File=""):\r
+        SqlCommand = """update Report set BelongsToItem=%s where BelongsToTable='File' and BelongsToItem=-2\r
+                        and OtherMsg like '%%%s%%'""" % (ItemID, File)\r
+        return self.Exec(SqlCommand)\r
+\r
     ## Convert to CSV\r
     #\r
     # Get all enabled records from table report and save them to a .csv file\r
     #\r
     # @param Filename:  To filename to save the report content\r
     #\r
-    def ToCSV(self, Filename = 'Report.csv'):\r
+    def ToCSV(self, Filename='Report.csv'):\r
         try:\r
             File = open(Filename, 'w+')\r
             File.write("""No, Error Code, Error Message, File, LineNo, Other Error Message\n""")\r
@@ -105,7 +114,7 @@ class TableReport(Table):
                 IsCorrected = Record[5]\r
                 SqlCommand = ''\r
                 if BelongsToTable == 'File':\r
-                    SqlCommand = """select 0, FullPath from %s where ID = %s\r
+                    SqlCommand = """select 1, FullPath from %s where ID = %s\r
                              """ % (BelongsToTable, BelongsToItem)\r
                 else:\r
                     SqlCommand = """select A.StartLine, B.FullPath from %s as A, File as B\r
@@ -115,7 +124,7 @@ class TableReport(Table):
                 if NewRecord != []:\r
                     File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % (Index, ErrorID, EccToolError.gEccErrorMessage[ErrorID], NewRecord[0][1], NewRecord[0][0], OtherMsg))\r
                     EdkLogger.quiet("%s(%s): [%s]%s %s" % (NewRecord[0][1], NewRecord[0][0], ErrorID, EccToolError.gEccErrorMessage[ErrorID], OtherMsg))\r
-                    \r
+\r
             File.close()\r
         except IOError:\r
             NewFilename = 'Report_' + time.strftime("%Y%m%d_%H%M%S.csv", time.localtime())\r