mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Import Books now working in ui, Working on logging.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
from loguru import logger
|
||||
|
||||
|
||||
class Config:
|
||||
@@ -17,6 +16,8 @@ class Config:
|
||||
"""
|
||||
_cp = pathlib.Path.joinpath(root, self._fp)
|
||||
_data = self.open_file(_cp)
|
||||
self.root = root
|
||||
self.logger = self.get_logger()
|
||||
self.book_path = _data["BOOKPATH"]
|
||||
self.TITLE = _data["TITLE"]
|
||||
self.VERSION = _data["VERSION"]
|
||||
@@ -30,7 +31,6 @@ class Config:
|
||||
self.file_array = [
|
||||
self.book_shelf,
|
||||
]
|
||||
self.root = root
|
||||
self.auto_scan = True
|
||||
|
||||
self.allowed_hosts = _data["ALLOWED_HOSTS"]
|
||||
@@ -38,7 +38,13 @@ class Config:
|
||||
self.db_pass = _data["PASSWORD"]
|
||||
self.SECRET = _data["SECRET"]
|
||||
|
||||
def open_file(self, _cp):
|
||||
def get_logger(self):
|
||||
_logger = logger
|
||||
_logger.add(pathlib.PurePath(self.root, 'data','pyShelf_{time}.log'), rotation="10 MB", loop=None)
|
||||
return _logger
|
||||
|
||||
@staticmethod
|
||||
def open_file(_cp):
|
||||
"""
|
||||
Opens config.json and reads in configuration options
|
||||
"""
|
||||
@@ -48,4 +54,3 @@ class Config:
|
||||
|
||||
def django_secret(self, _data):
|
||||
pass
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ from .api_hooks import DuckDuckGo
|
||||
from .config import Config
|
||||
from .storage import Storage
|
||||
|
||||
# config = Config()
|
||||
|
||||
|
||||
class Catalogue:
|
||||
@@ -51,6 +50,7 @@ class Catalogue:
|
||||
self.file_list.append(self.scan_folder(_path))
|
||||
else:
|
||||
self.file_list.append(_path)
|
||||
self.config.logger.info(_path)
|
||||
print(_path+"\n")
|
||||
|
||||
def filter_books(self):
|
||||
@@ -73,6 +73,7 @@ class Catalogue:
|
||||
"""
|
||||
|
||||
def process_by_filetype(self, book):
|
||||
|
||||
print(str(book), end='\r', flush=True)
|
||||
if book.endswith(".epub"):
|
||||
epub = self.process_epub(book)
|
||||
@@ -282,7 +283,6 @@ class Catalogue:
|
||||
with open(fsocket, 'w') as _socket:
|
||||
_socket.write(book[0])
|
||||
_socket.close()
|
||||
breakpoint()
|
||||
db.insert_book(book)
|
||||
inserted = db.commit()
|
||||
if inserted is not True:
|
||||
|
||||
Reference in New Issue
Block a user