]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/Table/TableEotReport.py
BaseTools/Ecc: Fix import issues
[mirror_edk2.git] / BaseTools / Source / Python / Table / TableEotReport.py
CommitLineData
30fdf114
LG
1## @file\r
2# This file is used to create/update/query/erase table for ECC reports\r
3#\r
f7496d71 4# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
40d841f6 5# This program and the accompanying materials\r
30fdf114
LG
6# are licensed and made available under the terms and conditions of the BSD License\r
7# which accompanies this distribution. The full text of the license may be found at\r
8# http://opensource.org/licenses/bsd-license.php\r
9#\r
10# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12#\r
13\r
14##\r
15# Import Modules\r
16#\r
3d872904 17from __future__ import absolute_import\r
30fdf114 18import Common.EdkLogger as EdkLogger\r
1be2ed90 19import Common.LongFilePathOs as os, time\r
855698fb 20from Table.Table import Table\r
5a57246e 21from Common.StringUtils import ConvertToSqlString2\r
52302d4d
LG
22import Eot.EotToolError as EotToolError\r
23import Eot.EotGlobalData as EotGlobalData\r
30fdf114
LG
24\r
25## TableReport\r
26#\r
27# This class defined a table used for data model\r
f7496d71 28#\r
30fdf114
LG
29# @param object: Inherited from object class\r
30#\r
31#\r
32class TableEotReport(Table):\r
33 def __init__(self, Cursor):\r
34 Table.__init__(self, Cursor)\r
35 self.Table = 'Report'\r
f7496d71 36\r
30fdf114
LG
37 ## Create table\r
38 #\r
39 # Create table report\r
40 #\r
41 #\r
42 def Create(self):\r
43 SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,\r
44 ModuleID INTEGER DEFAULT -1,\r
45 ModuleName TEXT DEFAULT '',\r
46 ModuleGuid TEXT DEFAULT '',\r
47 SourceFileID INTEGER DEFAULT -1,\r
48 SourceFileFullPath TEXT DEFAULT '',\r
49 ItemName TEXT DEFAULT '',\r
50 ItemType TEXT DEFAULT '',\r
51 ItemMode TEXT DEFAULT '',\r
52 GuidName TEXT DEFAULT '',\r
53 GuidMacro TEXT DEFAULT '',\r
54 GuidValue TEXT DEFAULT '',\r
55 BelongsToFunction TEXT DEFAULT '',\r
56 Enabled INTEGER DEFAULT 0\r
57 )""" % self.Table\r
58 Table.Create(self, SqlCommand)\r
59\r
60 ## Insert table\r
61 #\r
62 # Insert a record into table report\r
63 #\r
64 #\r
65 def Insert(self, ModuleID = -1, ModuleName = '', ModuleGuid = '', SourceFileID = -1, SourceFileFullPath = '', \\r
66 ItemName = '', ItemType = '', ItemMode = '', GuidName = '', GuidMacro = '', GuidValue = '', BelongsToFunction = '', Enabled = 0):\r
67 self.ID = self.ID + 1\r
68 SqlCommand = """insert into %s values(%s, %s, '%s', '%s', %s, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %s)""" \\r
69 % (self.Table, self.ID, ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, \\r
70 ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled)\r
71 Table.Insert(self, SqlCommand)\r
f7496d71 72\r
30fdf114
LG
73 def GetMaxID(self):\r
74 SqlCommand = """select max(ID) from %s""" % self.Table\r
75 self.Cur.execute(SqlCommand)\r
76 for Item in self.Cur:\r
f7496d71 77 return Item[0]\r