FIX: fixed the MD5 cmoparison
This commit is contained in:
parent
2271075114
commit
0862011ee6
|
@ -6,6 +6,7 @@ import json
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import hashlib
|
import hashlib
|
||||||
import time
|
import time
|
||||||
|
import logging
|
||||||
from libs import toolbox
|
from libs import toolbox
|
||||||
from libs.exceptions import FingerprintWrite
|
from libs.exceptions import FingerprintWrite
|
||||||
|
|
||||||
|
@ -132,13 +133,14 @@ class DBSchema:
|
||||||
try:
|
try:
|
||||||
fh = open(file_json, "r")
|
fh = open(file_json, "r")
|
||||||
jsonData = json.load(fh)
|
jsonData = json.load(fh)
|
||||||
dbmt = jsonData['db-metadata']
|
|
||||||
tb = jsonData['tables']
|
tb = jsonData['tables']
|
||||||
|
dbmt = jsonData['db-metadata']
|
||||||
|
dbht = jsonData['db-metadata-hashes']
|
||||||
all_tables = tb.keys()
|
all_tables = tb.keys()
|
||||||
for table_name in all_tables:
|
for table_name in all_tables:
|
||||||
print "[[ Table <" + table_name + "> imported ]]"
|
print "[[ Table <" + table_name + "> imported ]]"
|
||||||
newTable = TableDefinition()
|
newTable = TableDefinition()
|
||||||
newTable.importTable(table_name, dbmt[table_name], tb[table_name])
|
newTable.importTable(table_name, tb[table_name], dbmt[table_name], dbht[table_name])
|
||||||
tables[table_name] = newTable
|
tables[table_name] = newTable
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
@ -148,6 +150,9 @@ class DBSchema:
|
||||||
return tables
|
return tables
|
||||||
|
|
||||||
|
|
||||||
|
def __DBMD5Compare(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def __DBSchemaCompare(self):
|
def __DBSchemaCompare(self):
|
||||||
# the json database schema definition is what our tools is expecting...
|
# the json database schema definition is what our tools is expecting...
|
||||||
# ...so we use it as the baseline
|
# ...so we use it as the baseline
|
||||||
|
@ -162,6 +167,7 @@ class DBSchema:
|
||||||
print "[[ Comparing Table: " + tableName + " ]]"
|
print "[[ Comparing Table: " + tableName + " ]]"
|
||||||
if (table):
|
if (table):
|
||||||
if not (self.tablesJson[tableName].hash() == table.hash()):
|
if not (self.tablesJson[tableName].hash() == table.hash()):
|
||||||
|
logging.info("*** Hash difference 1:{}!={}".format(self.tablesJson[tableName].hash(), table.hash()))
|
||||||
(total, diff_num) = self.__CompareTable(self.tablesJson[tableName], table)
|
(total, diff_num) = self.__CompareTable(self.tablesJson[tableName], table)
|
||||||
all_total += total
|
all_total += total
|
||||||
diff_total += diff_num
|
diff_total += diff_num
|
||||||
|
@ -343,10 +349,11 @@ class TableDefinition:
|
||||||
del newField['name']
|
del newField['name']
|
||||||
|
|
||||||
#
|
#
|
||||||
def importTable(self, tbName, sqlStr, fields):
|
def importTable(self, tbName, fields, sqlStr, hashStr):
|
||||||
self.tableName = tbName
|
self.tableName = tbName
|
||||||
self.sqlStr = sqlStr
|
self.sqlStr = sqlStr
|
||||||
self.fields = fields
|
self.fields = fields
|
||||||
|
self.sqlStrHash = hashStr
|
||||||
|
|
||||||
|
|
||||||
# Table Definition
|
# Table Definition
|
||||||
|
|
Loading…
Reference in New Issue