ui gets v# from config

This commit is contained in:
th3r00t
2020-02-05 13:11:46 -05:00
parent 34e1228e81
commit 15e4960e33
8 changed files with 114 additions and 12 deletions

View File

@@ -1,9 +1,7 @@
#!/usr/bin/python
import sqlite3
import psycopg2
from psycopg2 import Error
from .config import Config
# db_pointer = Config().catalogue_db
@@ -102,3 +100,29 @@ class Storage:
"""
self.db.close()
return True
def make_collections(self):
_q = "SELECT id,file_name FROM books"
self.cursor.execute(_q)
_set = self.cursor.fetchall()
for book in _set:
path = self.config.book_path+'/'
_collections = []
_pathing = book[1].split(path)[1].split('/')
_pathing.pop(0);_pathing.pop(-1)
for _p in _pathing:
_s = _p.replace("'","")
_q_x = """
SELECT id FROM collections where collection='%s' AND book_id_id=%s
"""%(_s,book[0])
try:
self.cursor.execute(_q_x)
if len(self.cursor.fetchall()) < 1:
self.cursor.execute(
"""INSERT INTO collections (collection, book_id_id) VALUES ('%s',%s)"""%(_s,book[0])
)
except Exception as e:
print(e)
_collections.append(_p)
self.db.commit()
self.close()

View File

@@ -0,0 +1,23 @@
#!/usr/bin/python
import os
import sys
import time
from .lib.config import Config
from .lib.library import Catalogue
from .lib.pyShelf import InitFiles
from .lib.storage import Storage
sys.path.append(os.path.abspath("."))
def MakeCollections(root):
_t1 = time.time()
config = Config(root) # Get configuration settings
# InitFiles(config.file_array) # Initialize file system
_storage = Storage(config)
_storage.make_collections()
_t2 = time.time()
scan_time = round(_t2 - _t1)
print("Collections Made.")
print("Time %s seconds" % scan_time)

View File

@@ -19,7 +19,6 @@ def execute_scan(root):
_t1 = time.time()
config = Config(root) # Get configuration settings
InitFiles(config.file_array) # Initialize file system
Storage(config).check_ownership()
catalogue = Catalogue(config) # Open the Catalogue
catalogue.import_books()