WIP: adding functions to use index
This commit is contained in:
parent
b6c6e0f600
commit
a39dad4f18
|
@ -37,6 +37,8 @@ class FingerprintIndex:
|
||||||
logging.info("No index file found, creating index now...")
|
logging.info("No index file found, creating index now...")
|
||||||
self.createIndex(fp_dir)
|
self.createIndex(fp_dir)
|
||||||
self.db_conn = sql.connect(fq_fpidx)
|
self.db_conn = sql.connect(fq_fpidx)
|
||||||
|
|
||||||
|
self.cur = self.db_conn.cursor()
|
||||||
except:
|
except:
|
||||||
if self.db_conn:
|
if self.db_conn:
|
||||||
self.db_conn.close()
|
self.db_conn.close()
|
||||||
|
@ -64,20 +66,41 @@ class FingerprintIndex:
|
||||||
logging.info("Successfully created index table")
|
logging.info("Successfully created index table")
|
||||||
self.__populateIndex(fp_dir)
|
self.__populateIndex(fp_dir)
|
||||||
logging.info("Successfully populated the index")
|
logging.info("Successfully populated the index")
|
||||||
except Exception as e:
|
except Exception as ex:
|
||||||
raise FingerprintIndexWrite("Error creating an index file\n{}".format(e))
|
raise FingerprintIndexWrite("Error creating an index file\n{}".format(ex))
|
||||||
finally:
|
finally:
|
||||||
if self.db_conn:
|
if self.db_conn:
|
||||||
self.db_conn.close()
|
self.db_conn.close()
|
||||||
self.db_conn = None
|
self.db_conn = None
|
||||||
|
|
||||||
|
#
|
||||||
|
def qDatabaseMD5(self, md5_db):
|
||||||
|
try:
|
||||||
|
rows = self.cur.execute('''
|
||||||
|
SELECT md5_list, fp_list, fp_count
|
||||||
|
FROM md5_all
|
||||||
|
WHERE md5_db=?
|
||||||
|
''', [md5_db])
|
||||||
|
except Exception as ex:
|
||||||
|
logging.error(ex)
|
||||||
|
|
||||||
|
#
|
||||||
|
def qTableMD5(self, md5_table):
|
||||||
|
try:
|
||||||
|
rows = self.cur.execute('''
|
||||||
|
SELECT fp_list, fp_count
|
||||||
|
FROM md5_tables
|
||||||
|
WHERE md5_table=?
|
||||||
|
''', [md5_table])
|
||||||
|
except Exception as ex:
|
||||||
|
logging.error(ex)
|
||||||
|
|
||||||
#
|
#
|
||||||
def __populateIndex(self, fp_dir):
|
def __populateIndex(self, fp_dir):
|
||||||
""" read each file, pull md5, add row to database """
|
""" read each file, pull md5, add row to database """
|
||||||
failCount = 0
|
failCount = 0
|
||||||
finCount = 0
|
finCount = 0
|
||||||
try:
|
try:
|
||||||
self.cur = self.db_conn.cursor()
|
|
||||||
db = FingerprintDB()
|
db = FingerprintDB()
|
||||||
files = os.listdir(fp_dir)
|
files = os.listdir(fp_dir)
|
||||||
for file in files:
|
for file in files:
|
||||||
|
|
Loading…
Reference in New Issue