Check In tool source code based on Build tool project revision r1655.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8964 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4
2009-07-17 09:10:31 +00:00
parent 577e30cdb4
commit 30fdf1140b
532 changed files with 231447 additions and 32 deletions

View File

@ -0,0 +1,120 @@
## @file
# This file is used to create/update/query/erase a common table
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
## TableFile
#
# This class defined a common table
#
# @param object: Inherited from object class
#
# @param Cursor: Cursor of the database
# @param TableName: Name of the table
#
class Table(object):
def __init__(self, Cursor):
self.Cur = Cursor
self.Table = ''
self.ID = 0
## Create table
#
# Create a table
#
def Create(self, SqlCommand):
self.Cur.execute(SqlCommand)
self.ID = 0
EdkLogger.verbose(SqlCommand + " ... DONE!")
## Insert table
#
# Insert a record into a table
#
def Insert(self, SqlCommand):
self.Exec(SqlCommand)
## Query table
#
# Query all records of the table
#
def Query(self):
EdkLogger.verbose("\nQuery tabel %s started ..." % self.Table)
SqlCommand = """select * from %s""" % self.Table
self.Cur.execute(SqlCommand)
for Rs in self.Cur:
EdkLogger.verbose(str(Rs))
TotalCount = self.GetCount()
EdkLogger.verbose("*** Total %s records in table %s ***" % (TotalCount, self.Table) )
EdkLogger.verbose("Query tabel %s DONE!" % self.Table)
## Drop a table
#
# Drop the table
#
def Drop(self):
SqlCommand = """drop table IF EXISTS %s""" % self.Table
self.Cur.execute(SqlCommand)
EdkLogger.verbose("Drop tabel %s ... DONE!" % self.Table)
## Get count
#
# Get a count of all records of the table
#
# @retval Count: Total count of all records
#
def GetCount(self):
SqlCommand = """select count(ID) from %s""" % self.Table
self.Cur.execute(SqlCommand)
for Item in self.Cur:
return Item[0]
## Generate ID
#
# Generate an ID if input ID is -1
#
# @param ID: Input ID
#
# @retval ID: New generated ID
#
def GenerateID(self, ID):
if ID == -1:
self.ID = self.ID + 1
return self.ID
## Init the ID of the table
#
# Init the ID of the table
#
def InitID(self):
self.ID = self.GetCount()
## Exec
#
# Exec Sql Command, return result
#
# @param SqlCommand: The SqlCommand to be executed
#
# @retval RecordSet: The result after executed
#
def Exec(self, SqlCommand):
EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
self.Cur.execute(SqlCommand)
RecordSet = self.Cur.fetchall()
EdkLogger.debug(4, "RecordSet: %s" % RecordSet)
return RecordSet

View File

@ -0,0 +1,95 @@
## @file
# This file is used to create/update/query/erase table for data models
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
from Table import Table
from Common.String import ConvertToSqlString
## TableDataModel
#
# This class defined a table used for data model
#
# @param object: Inherited from object class
#
#
class TableDataModel(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'DataModel'
## Create table
#
# Create table DataModel
#
# @param ID: ID of a ModelType
# @param CrossIndex: CrossIndex of a ModelType
# @param Name: Name of a ModelType
# @param Description: Description of a ModelType
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
CrossIndex INTEGER NOT NULL,
Name VARCHAR NOT NULL,
Description VARCHAR
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table DataModel
#
# @param ID: ID of a ModelType
# @param CrossIndex: CrossIndex of a ModelType
# @param Name: Name of a ModelType
# @param Description: Description of a ModelType
#
def Insert(self, CrossIndex, Name, Description):
self.ID = self.ID + 1
(Name, Description) = ConvertToSqlString((Name, Description))
SqlCommand = """insert into %s values(%s, %s, '%s', '%s')""" % (self.Table, self.ID, CrossIndex, Name, Description)
Table.Insert(self, SqlCommand)
return self.ID
## Init table
#
# Create all default records of table DataModel
#
def InitTable(self):
EdkLogger.verbose("\nInitialize table DataModel started ...")
for Item in DataClass.MODEL_LIST:
CrossIndex = Item[1]
Name = Item[0]
Description = Item[0]
self.Insert(CrossIndex, Name, Description)
EdkLogger.verbose("Initialize table DataModel ... DONE!")
## Get CrossIndex
#
# Get a model's cross index from its name
#
# @param ModelName: Name of the model
# @retval CrossIndex: CrossIndex of the model
#
def GetCrossIndex(self, ModelName):
CrossIndex = -1
SqlCommand = """select CrossIndex from DataModel where name = '""" + ModelName + """'"""
self.Cur.execute(SqlCommand)
for Item in self.Cur:
CrossIndex = Item[0]
return CrossIndex

View File

@ -0,0 +1,108 @@
## @file
# This file is used to create/update/query/erase table for dec datas
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
from Table import Table
from Common.String import ConvertToSqlString
## TableDec
#
# This class defined a table used for data model
#
# @param object: Inherited from object class
#
#
class TableDec(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Dec'
## Create table
#
# Create table Dec
#
# @param ID: ID of a Dec item
# @param Model: Model of a Dec item
# @param Value1: Value1 of a Dec item
# @param Value2: Value2 of a Dec item
# @param Value3: Value3 of a Dec item
# @param Arch: Arch of a Dec item
# @param BelongsToItem: The item belongs to which another item
# @param BelongsToFile: The item belongs to which dsc file
# @param StartLine: StartLine of a Dec item
# @param StartColumn: StartColumn of a Dec item
# @param EndLine: EndLine of a Dec item
# @param EndColumn: EndColumn of a Dec item
# @param Enabled: If this item enabled
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
Model INTEGER NOT NULL,
Value1 VARCHAR NOT NULL,
Value2 VARCHAR,
Value3 VARCHAR,
Arch VarCHAR,
BelongsToItem SINGLE NOT NULL,
BelongsToFile SINGLE NOT NULL,
StartLine INTEGER NOT NULL,
StartColumn INTEGER NOT NULL,
EndLine INTEGER NOT NULL,
EndColumn INTEGER NOT NULL,
Enabled INTEGER DEFAULT 0
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table Dec
#
# @param ID: ID of a Dec item
# @param Model: Model of a Dec item
# @param Value1: Value1 of a Dec item
# @param Value2: Value2 of a Dec item
# @param Value3: Value3 of a Dec item
# @param Arch: Arch of a Dec item
# @param BelongsToItem: The item belongs to which another item
# @param BelongsToFile: The item belongs to which dsc file
# @param StartLine: StartLine of a Dec item
# @param StartColumn: StartColumn of a Dec item
# @param EndLine: EndLine of a Dec item
# @param EndColumn: EndColumn of a Dec item
# @param Enabled: If this item enabled
#
def Insert(self, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
self.ID = self.ID + 1
(Value1, Value2, Value3, Arch) = ConvertToSqlString((Value1, Value2, Value3, Arch))
SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
% (self.Table, self.ID, Model, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)
Table.Insert(self, SqlCommand)
return self.ID
## Query table
#
# @param Model: The Model of Record
#
# @retval: A recordSet of all found records
#
def Query(self, Model):
SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
where Model = %s
and Enabled > -1""" % (self.Table, Model)
EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
self.Cur.execute(SqlCommand)
return self.Cur.fetchall()

View File

@ -0,0 +1,108 @@
## @file
# This file is used to create/update/query/erase table for dsc datas
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
from Table import Table
from Common.String import ConvertToSqlString
## TableDsc
#
# This class defined a table used for data model
#
# @param object: Inherited from object class
#
#
class TableDsc(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Dsc'
## Create table
#
# Create table Dsc
#
# @param ID: ID of a Dsc item
# @param Model: Model of a Dsc item
# @param Value1: Value1 of a Dsc item
# @param Value2: Value2 of a Dsc item
# @param Value3: Value3 of a Dsc item
# @param Arch: Arch of a Dsc item
# @param BelongsToItem: The item belongs to which another item
# @param BelongsToFile: The item belongs to which dsc file
# @param StartLine: StartLine of a Dsc item
# @param StartColumn: StartColumn of a Dsc item
# @param EndLine: EndLine of a Dsc item
# @param EndColumn: EndColumn of a Dsc item
# @param Enabled: If this item enabled
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
Model INTEGER NOT NULL,
Value1 VARCHAR NOT NULL,
Value2 VARCHAR,
Value3 VARCHAR,
Arch VarCHAR,
BelongsToItem SINGLE NOT NULL,
BelongsToFile SINGLE NOT NULL,
StartLine INTEGER NOT NULL,
StartColumn INTEGER NOT NULL,
EndLine INTEGER NOT NULL,
EndColumn INTEGER NOT NULL,
Enabled INTEGER DEFAULT 0
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table Dsc
#
# @param ID: ID of a Dsc item
# @param Model: Model of a Dsc item
# @param Value1: Value1 of a Dsc item
# @param Value2: Value2 of a Dsc item
# @param Value3: Value3 of a Dsc item
# @param Arch: Arch of a Dsc item
# @param BelongsToItem: The item belongs to which another item
# @param BelongsToFile: The item belongs to which dsc file
# @param StartLine: StartLine of a Dsc item
# @param StartColumn: StartColumn of a Dsc item
# @param EndLine: EndLine of a Dsc item
# @param EndColumn: EndColumn of a Dsc item
# @param Enabled: If this item enabled
#
def Insert(self, Model, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
self.ID = self.ID + 1
(Value1, Value2, Value3, Arch) = ConvertToSqlString((Value1, Value2, Value3, Arch))
SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
% (self.Table, self.ID, Model, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)
Table.Insert(self, SqlCommand)
return self.ID
## Query table
#
# @param Model: The Model of Record
#
# @retval: A recordSet of all found records
#
def Query(self, Model):
SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
where Model = %s
and Enabled > -1""" % (self.Table, Model)
EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
self.Cur.execute(SqlCommand)
return self.Cur.fetchall()

View File

@ -0,0 +1,76 @@
## @file
# This file is used to create/update/query/erase table for ECC reports
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
import os, time
from Table import Table
from Common.String import ConvertToSqlString2
import EotToolError as EotToolError
import EotGlobalData as EotGlobalData
## TableReport
#
# This class defined a table used for data model
#
# @param object: Inherited from object class
#
#
class TableEotReport(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Report'
## Create table
#
# Create table report
#
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
ModuleID INTEGER DEFAULT -1,
ModuleName TEXT DEFAULT '',
ModuleGuid TEXT DEFAULT '',
SourceFileID INTEGER DEFAULT -1,
SourceFileFullPath TEXT DEFAULT '',
ItemName TEXT DEFAULT '',
ItemType TEXT DEFAULT '',
ItemMode TEXT DEFAULT '',
GuidName TEXT DEFAULT '',
GuidMacro TEXT DEFAULT '',
GuidValue TEXT DEFAULT '',
BelongsToFunction TEXT DEFAULT '',
Enabled INTEGER DEFAULT 0
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table report
#
#
def Insert(self, ModuleID = -1, ModuleName = '', ModuleGuid = '', SourceFileID = -1, SourceFileFullPath = '', \
ItemName = '', ItemType = '', ItemMode = '', GuidName = '', GuidMacro = '', GuidValue = '', BelongsToFunction = '', Enabled = 0):
self.ID = self.ID + 1
SqlCommand = """insert into %s values(%s, %s, '%s', '%s', %s, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %s)""" \
% (self.Table, self.ID, ModuleID, ModuleName, ModuleGuid, SourceFileID, SourceFileFullPath, \
ItemName, ItemType, ItemMode, GuidName, GuidMacro, GuidValue, BelongsToFunction, Enabled)
Table.Insert(self, SqlCommand)
def GetMaxID(self):
SqlCommand = """select max(ID) from %s""" % self.Table
self.Cur.execute(SqlCommand)
for Item in self.Cur:
return Item[0]

View File

@ -0,0 +1,108 @@
## @file
# This file is used to create/update/query/erase table for fdf datas
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
from Table import Table
from Common.String import ConvertToSqlString
## TableFdf
#
# This class defined a table used for data model
#
# @param object: Inherited from object class
#
#
class TableFdf(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Fdf'
## Create table
#
# Create table Fdf
#
# @param ID: ID of a Fdf item
# @param Model: Model of a Fdf item
# @param Value1: Value1 of a Fdf item
# @param Value2: Value2 of a Fdf item
# @param Value3: Value3 of a Fdf item
# @param Arch: Arch of a Fdf item
# @param BelongsToItem: The item belongs to which another item
# @param BelongsToFile: The item belongs to which fdf file
# @param StartLine: StartLine of a Fdf item
# @param StartColumn: StartColumn of a Fdf item
# @param EndLine: EndLine of a Fdf item
# @param EndColumn: EndColumn of a Fdf item
# @param Enabled: If this item enabled
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
Model INTEGER NOT NULL,
Value1 VARCHAR NOT NULL,
Value2 VARCHAR,
Value3 VARCHAR,
Arch VarCHAR,
BelongsToItem SINGLE NOT NULL,
BelongsToFile SINGLE NOT NULL,
StartLine INTEGER NOT NULL,
StartColumn INTEGER NOT NULL,
EndLine INTEGER NOT NULL,
EndColumn INTEGER NOT NULL,
Enabled INTEGER DEFAULT 0
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table Fdf
#
# @param ID: ID of a Fdf item
# @param Model: Model of a Fdf item
# @param Value1: Value1 of a Fdf item
# @param Value2: Value2 of a Fdf item
# @param Value3: Value3 of a Fdf item
# @param Arch: Arch of a Fdf item
# @param BelongsToItem: The item belongs to which another item
# @param BelongsToFile: The item belongs to which fdf file
# @param StartLine: StartLine of a Fdf item
# @param StartColumn: StartColumn of a Fdf item
# @param EndLine: EndLine of a Fdf item
# @param EndColumn: EndColumn of a Fdf item
# @param Enabled: If this item enabled
#
def Insert(self, Model, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
self.ID = self.ID + 1
(Value1, Value2, Value3, Arch) = ConvertToSqlString((Value1, Value2, Value3, Arch))
SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
% (self.Table, self.ID, Model, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)
Table.Insert(self, SqlCommand)
return self.ID
## Query table
#
# @param Model: The Model of Record
#
# @retval: A recordSet of all found records
#
def Query(self, Model):
SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
where Model = %s
and Enabled > -1""" % (self.Table, Model)
EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
self.Cur.execute(SqlCommand)
return self.Cur.fetchall()

View File

@ -0,0 +1,91 @@
## @file
# This file is used to create/update/query/erase table for files
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
from Table import Table
from Common.String import ConvertToSqlString
import os
from CommonDataClass.DataClass import FileClass
## TableFile
#
# This class defined a table used for file
#
# @param object: Inherited from object class
#
class TableFile(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'File'
## Create table
#
# Create table File
#
# @param ID: ID of a File
# @param Name: Name of a File
# @param ExtName: ExtName of a File
# @param Path: Path of a File
# @param FullPath: FullPath of a File
# @param Model: Model of a File
# @param TimeStamp: TimeStamp of a File
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
Name VARCHAR NOT NULL,
ExtName VARCHAR,
Path VARCHAR,
FullPath VARCHAR NOT NULL,
Model INTEGER DEFAULT 0,
TimeStamp VARCHAR NOT NULL
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table File
#
# @param ID: ID of a File
# @param Name: Name of a File
# @param ExtName: ExtName of a File
# @param Path: Path of a File
# @param FullPath: FullPath of a File
# @param Model: Model of a File
# @param TimeStamp: TimeStamp of a File
#
def Insert(self, Name, ExtName, Path, FullPath, Model, TimeStamp):
self.ID = self.ID + 1
(Name, ExtName, Path, FullPath) = ConvertToSqlString((Name, ExtName, Path, FullPath))
SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, '%s')""" \
% (self.Table, self.ID, Name, ExtName, Path, FullPath, Model, TimeStamp)
Table.Insert(self, SqlCommand)
return self.ID
## InsertFile
#
# Insert one file to table
#
# @param FileFullPath: The full path of the file
# @param Model: The model of the file
#
# @retval FileID: The ID after record is inserted
#
def InsertFile(self, FileFullPath, Model):
(Filepath, Name) = os.path.split(FileFullPath)
(Root, Ext) = os.path.splitext(FileFullPath)
TimeStamp = os.stat(FileFullPath)[8]
File = FileClass(-1, Name, Ext, Filepath, FileFullPath, Model, '', [], [], [])
return self.Insert(File.Name, File.ExtName, File.Path, File.FullPath, File.Model, TimeStamp)

View File

@ -0,0 +1,95 @@
## @file
# This file is used to create/update/query/erase table for functions
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
from Table import Table
from Common.String import ConvertToSqlString
## TableFunction
#
# This class defined a table used for function
#
# @param Table: Inherited from Table class
#
class TableFunction(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Function'
## Create table
#
# Create table Function
#
# @param ID: ID of a Function
# @param Header: Header of a Function
# @param Modifier: Modifier of a Function
# @param Name: Name of a Function
# @param ReturnStatement: ReturnStatement of a Funciont
# @param StartLine: StartLine of a Function
# @param StartColumn: StartColumn of a Function
# @param EndLine: EndLine of a Function
# @param EndColumn: EndColumn of a Function
# @param BodyStartLine: StartLine of a Function body
# @param BodyStartColumn: StartColumn of a Function body
# @param BelongsToFile: The Function belongs to which file
# @param FunNameStartLine: StartLine of a Function name
# @param FunNameStartColumn: StartColumn of a Function name
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
Header TEXT,
Modifier VARCHAR,
Name VARCHAR NOT NULL,
ReturnStatement VARCHAR,
StartLine INTEGER NOT NULL,
StartColumn INTEGER NOT NULL,
EndLine INTEGER NOT NULL,
EndColumn INTEGER NOT NULL,
BodyStartLine INTEGER NOT NULL,
BodyStartColumn INTEGER NOT NULL,
BelongsToFile SINGLE NOT NULL,
FunNameStartLine INTEGER NOT NULL,
FunNameStartColumn INTEGER NOT NULL
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table Function
#
# @param ID: ID of a Function
# @param Header: Header of a Function
# @param Modifier: Modifier of a Function
# @param Name: Name of a Function
# @param ReturnStatement: ReturnStatement of a Funciont
# @param StartLine: StartLine of a Function
# @param StartColumn: StartColumn of a Function
# @param EndLine: EndLine of a Function
# @param EndColumn: EndColumn of a Function
# @param BodyStartLine: StartLine of a Function body
# @param BodyStartColumn: StartColumn of a Function body
# @param BelongsToFile: The Function belongs to which file
# @param FunNameStartLine: StartLine of a Function name
# @param FunNameStartColumn: StartColumn of a Function name
#
def Insert(self, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn):
self.ID = self.ID + 1
(Header, Modifier, Name, ReturnStatement) = ConvertToSqlString((Header, Modifier, Name, ReturnStatement))
SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s, %s, %s)""" \
% (self.Table, self.ID, Header, Modifier, Name, ReturnStatement, StartLine, StartColumn, EndLine, EndColumn, BodyStartLine, BodyStartColumn, BelongsToFile, FunNameStartLine, FunNameStartColumn)
Table.Insert(self, SqlCommand)
return self.ID

View File

@ -0,0 +1,90 @@
## @file
# This file is used to create/update/query/erase table for Identifiers
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
from Common.String import ConvertToSqlString
from Table import Table
## TableIdentifier
#
# This class defined a table used for Identifier
#
# @param object: Inherited from object class
#
#
class TableIdentifier(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Identifier'
## Create table
#
# Create table Identifier
#
# @param ID: ID of a Identifier
# @param Modifier: Modifier of a Identifier
# @param Type: Type of a Identifier
# @param Name: Name of a Identifier
# @param Value: Value of a Identifier
# @param Model: Model of a Identifier
# @param BelongsToFile: The Identifier belongs to which file
# @param BelongsToFunction: The Identifier belongs to which function
# @param StartLine: StartLine of a Identifier
# @param StartColumn: StartColumn of a Identifier
# @param EndLine: EndLine of a Identifier
# @param EndColumn: EndColumn of a Identifier
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
Modifier VARCHAR,
Type VARCHAR,
Name VARCHAR NOT NULL,
Value VARCHAR NOT NULL,
Model INTEGER NOT NULL,
BelongsToFile SINGLE NOT NULL,
BelongsToFunction SINGLE DEFAULT -1,
StartLine INTEGER NOT NULL,
StartColumn INTEGER NOT NULL,
EndLine INTEGER NOT NULL,
EndColumn INTEGER NOT NULL
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table Identifier
#
# @param ID: ID of a Identifier
# @param Modifier: Modifier of a Identifier
# @param Type: Type of a Identifier
# @param Name: Name of a Identifier
# @param Value: Value of a Identifier
# @param Model: Model of a Identifier
# @param BelongsToFile: The Identifier belongs to which file
# @param BelongsToFunction: The Identifier belongs to which function
# @param StartLine: StartLine of a Identifier
# @param StartColumn: StartColumn of a Identifier
# @param EndLine: EndLine of a Identifier
# @param EndColumn: EndColumn of a Identifier
#
def Insert(self, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn):
self.ID = self.ID + 1
(Modifier, Type, Name, Value) = ConvertToSqlString((Modifier, Type, Name, Value))
SqlCommand = """insert into %s values(%s, '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
% (self.Table, self.ID, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)
Table.Insert(self, SqlCommand)
return self.ID

View File

@ -0,0 +1,114 @@
## @file
# This file is used to create/update/query/erase table for inf datas
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
import CommonDataClass.DataClass as DataClass
from Table import Table
from Common.String import ConvertToSqlString
## TableInf
#
# This class defined a table used for data model
#
# @param object: Inherited from object class
#
#
class TableInf(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Inf'
## Create table
#
# Create table Inf
#
# @param ID: ID of a Inf item
# @param Model: Model of a Inf item
# @param Value1: Value1 of a Inf item
# @param Value2: Value2 of a Inf item
# @param Value3: Value3 of a Inf item
# @param Value4: Value4 of a Inf item
# @param Value5: Value5 of a Inf item
# @param Arch: Arch of a Inf item
# @param BelongsToItem: The item belongs to which another item
# @param BelongsToFile: The item belongs to which dsc file
# @param StartLine: StartLine of a Inf item
# @param StartColumn: StartColumn of a Inf item
# @param EndLine: EndLine of a Inf item
# @param EndColumn: EndColumn of a Inf item
# @param Enabled: If this item enabled
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
Model INTEGER NOT NULL,
Value1 VARCHAR NOT NULL,
Value2 VARCHAR,
Value3 VARCHAR,
Value4 VARCHAR,
Value5 VARCHAR,
Arch VarCHAR,
BelongsToItem SINGLE NOT NULL,
BelongsToFile SINGLE NOT NULL,
StartLine INTEGER NOT NULL,
StartColumn INTEGER NOT NULL,
EndLine INTEGER NOT NULL,
EndColumn INTEGER NOT NULL,
Enabled INTEGER DEFAULT 0
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table Inf
#
# @param ID: ID of a Inf item
# @param Model: Model of a Inf item
# @param Value1: Value1 of a Inf item
# @param Value2: Value2 of a Inf item
# @param Value3: Value3 of a Inf item
# @param Value4: Value4 of a Inf item
# @param Value5: Value5 of a Inf item
# @param Arch: Arch of a Inf item
# @param BelongsToItem: The item belongs to which another item
# @param BelongsToFile: The item belongs to which dsc file
# @param StartLine: StartLine of a Inf item
# @param StartColumn: StartColumn of a Inf item
# @param EndLine: EndLine of a Inf item
# @param EndColumn: EndColumn of a Inf item
# @param Enabled: If this item enabled
#
def Insert(self, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled):
self.ID = self.ID + 1
(Value1, Value2, Value3, Value4, Value5, Arch) = ConvertToSqlString((Value1, Value2, Value3, Value4, Value5, Arch))
SqlCommand = """insert into %s values(%s, %s, '%s', '%s', '%s', '%s', '%s', '%s', %s, %s, %s, %s, %s, %s, %s)""" \
% (self.Table, self.ID, Model, Value1, Value2, Value3, Value4, Value5, Arch, BelongsToItem, BelongsToFile, StartLine, StartColumn, EndLine, EndColumn, Enabled)
Table.Insert(self, SqlCommand)
return self.ID
## Query table
#
# @param Model: The Model of Record
#
# @retval: A recordSet of all found records
#
def Query(self, Model):
SqlCommand = """select ID, Value1, Value2, Value3, Arch, BelongsToItem, BelongsToFile, StartLine from %s
where Model = %s
and Enabled > -1""" % (self.Table, Model)
EdkLogger.debug(4, "SqlCommand: %s" % SqlCommand)
self.Cur.execute(SqlCommand)
return self.Cur.fetchall()

View File

@ -0,0 +1,90 @@
## @file
# This file is used to create/update/query/erase table for pcds
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
from Table import Table
from Common.String import ConvertToSqlString
## TablePcd
#
# This class defined a table used for pcds
#
# @param object: Inherited from object class
#
#
class TablePcd(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Pcd'
## Create table
#
# Create table Pcd
#
# @param ID: ID of a Pcd
# @param CName: CName of a Pcd
# @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
# @param Token: Token of a Pcd
# @param DatumType: DatumType of a Pcd
# @param Model: Model of a Pcd
# @param BelongsToFile: The Pcd belongs to which file
# @param BelongsToFunction: The Pcd belongs to which function
# @param StartLine: StartLine of a Pcd
# @param StartColumn: StartColumn of a Pcd
# @param EndLine: EndLine of a Pcd
# @param EndColumn: EndColumn of a Pcd
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
CName VARCHAR NOT NULL,
TokenSpaceGuidCName VARCHAR NOT NULL,
Token INTEGER,
DatumType VARCHAR,
Model INTEGER NOT NULL,
BelongsToFile SINGLE NOT NULL,
BelongsToFunction SINGLE DEFAULT -1,
StartLine INTEGER NOT NULL,
StartColumn INTEGER NOT NULL,
EndLine INTEGER NOT NULL,
EndColumn INTEGER NOT NULL
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table Pcd
#
# @param ID: ID of a Pcd
# @param CName: CName of a Pcd
# @param TokenSpaceGuidCName: TokenSpaceGuidCName of a Pcd
# @param Token: Token of a Pcd
# @param DatumType: DatumType of a Pcd
# @param Model: Model of a Pcd
# @param BelongsToFile: The Pcd belongs to which file
# @param BelongsToFunction: The Pcd belongs to which function
# @param StartLine: StartLine of a Pcd
# @param StartColumn: StartColumn of a Pcd
# @param EndLine: EndLine of a Pcd
# @param EndColumn: EndColumn of a Pcd
#
def Insert(self, CName, TokenSpaceGuidCName, Token, DatumType, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn):
self.ID = self.ID + 1
(CName, TokenSpaceGuidCName, DatumType) = ConvertToSqlString((CName, TokenSpaceGuidCName, DatumType))
SqlCommand = """insert into %s values(%s, '%s', '%s', %s, '%s', %s, %s, %s, %s, %s, %s, %s)""" \
% (self.Table, self.ID, CName, TokenSpaceGuidCName, Token, DatumType, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn)
Table.Insert(self, SqlCommand)
return self.ID

View File

@ -0,0 +1,66 @@
## @file
# This file is used to create/update/query/erase table for Queries
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
from Common.String import ConvertToSqlString
from Table import Table
## TableQuery
#
# This class defined a table used for Query
#
# @param object: Inherited from object class
#
#
class TableQuery(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Query'
## Create table
#
# Create table Query
#
# @param ID: ID of a Query
# @param Name: Modifier of a Query
# @param Value: Type of a Query
# @param Model: Model of a Query
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s(ID INTEGER PRIMARY KEY,
Name TEXT DEFAULT '',
Value TEXT DEFAULT '',
Model INTEGER DEFAULT 0
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table Query
#
# @param ID: ID of a Query
# @param Name: Modifier of a Query
# @param Value: Type of a Query
# @param Model: Model of a Query
#
def Insert(self, Name, Value, Model):
self.ID = self.ID + 1
SqlCommand = """insert into %s values(%s, '%s', '%s', %s)""" \
% (self.Table, self.ID, Name, Value, Model)
Table.Insert(self, SqlCommand)
return self.ID

View File

@ -0,0 +1,123 @@
## @file
# This file is used to create/update/query/erase table for ECC reports
#
# Copyright (c) 2008, 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
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import Common.EdkLogger as EdkLogger
import os, time
from Table import Table
from Common.String import ConvertToSqlString2
import EccToolError as EccToolError
import EccGlobalData as EccGlobalData
## TableReport
#
# This class defined a table used for data model
#
# @param object: Inherited from object class
#
#
class TableReport(Table):
def __init__(self, Cursor):
Table.__init__(self, Cursor)
self.Table = 'Report'
## Create table
#
# Create table report
#
# @param ID: ID of an Error
# @param ErrorID: ID of an Error TypeModel of a Report item
# @param OtherMsg: Other error message besides the standard error message
# @param BelongsToItem: The error belongs to which item
# @param Enabled: If this error enabled
# @param Corrected: if this error corrected
#
def Create(self):
SqlCommand = """create table IF NOT EXISTS %s (ID INTEGER PRIMARY KEY,
ErrorID INTEGER NOT NULL,
OtherMsg TEXT,
BelongsToTable TEXT NOT NULL,
BelongsToItem SINGLE NOT NULL,
Enabled INTEGER DEFAULT 0,
Corrected INTEGER DEFAULT -1
)""" % self.Table
Table.Create(self, SqlCommand)
## Insert table
#
# Insert a record into table report
#
# @param ID: ID of an Error
# @param ErrorID: ID of an Error TypeModel of a report item
# @param OtherMsg: Other error message besides the standard error message
# @param BelongsToTable: The error item belongs to which table
# @param BelongsToItem: The error belongs to which item
# @param Enabled: If this error enabled
# @param Corrected: if this error corrected
#
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
#
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)
## 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'):
try:
File = open(Filename, 'w+')
File.write("""No, Error Code, Error Message, File, LineNo, Other Error Message\n""")
RecordSet = self.Query()
Index = 0
for Record in RecordSet:
Index = Index + 1
ErrorID = Record[1]
OtherMsg = Record[2]
BelongsToTable = Record[3]
BelongsToItem = Record[4]
IsCorrected = Record[5]
SqlCommand = ''
if BelongsToTable == 'File':
SqlCommand = """select 0, FullPath from %s where ID = %s
""" % (BelongsToTable, BelongsToItem)
else:
SqlCommand = """select A.StartLine, B.FullPath from %s as A, File as B
where A.ID = %s and B.ID = A.BelongsToFile
""" % (BelongsToTable, BelongsToItem)
NewRecord = self.Exec(SqlCommand)
if NewRecord != []:
File.write("""%s,%s,"%s",%s,%s,"%s"\n""" % (Index, ErrorID, EccToolError.gEccErrorMessage[ErrorID], NewRecord[0][1], NewRecord[0][0], OtherMsg))
File.close()
except IOError:
NewFilename = 'Report_' + time.strftime("%Y%m%d_%H%M%S.csv", time.localtime())
EdkLogger.warn("ECC", "The report file %s is locked by other progress, use %s instead!" % (Filename, NewFilename))
self.ToCSV(NewFilename)