mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Updated code to work with zipapp
This commit is contained in:
43
src/__main__.py
vendored
Executable file
43
src/__main__.py
vendored
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
"""PyShelf Entrypoint."""
|
||||
import asyncio
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from threading import Thread
|
||||
from backend.lib.config import Config
|
||||
from backend.lib.storage import Storage
|
||||
from backend.pyShelf_ScanLibrary import execute_scan
|
||||
from frontend.lib.FastAPIServer import FastAPIServer
|
||||
# import websockets
|
||||
|
||||
|
||||
root = Path.cwd()
|
||||
config = Config(root)
|
||||
PRG_PATH = Path.cwd().__str__()
|
||||
sys.path.insert(0, PRG_PATH)
|
||||
|
||||
|
||||
def run_import():
|
||||
"""Begin live import of books."""
|
||||
config.logger.info("Begining book import.")
|
||||
execute_scan(PRG_PATH, config=config)
|
||||
config.logger.info("Finished book import.")
|
||||
storage = Storage(config=config)
|
||||
# MakeCollections(PRG_PATH, config=config)
|
||||
storage.make_collections()
|
||||
return "Import Complete"
|
||||
|
||||
|
||||
async def main():
|
||||
"""Program entrypoint."""
|
||||
Storage(config=config).create_tables()
|
||||
_import_thread = Thread(target=run_import)
|
||||
_import_thread.start()
|
||||
fe_server = FastAPIServer(config)
|
||||
_task = await asyncio.create_task(fe_server.run())
|
||||
return [_task, _import_thread]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
sys.exit(0)
|
||||
4
src/frontend/lib/FastAPIServer.py
vendored
4
src/frontend/lib/FastAPIServer.py
vendored
@@ -14,9 +14,9 @@ from fastapi.routing import APIRoute
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.templating import Jinja2Templates
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from ...backend.lib.storage import Storage
|
||||
from backend.lib.storage import Storage
|
||||
from .objects import JSInterface
|
||||
from ...backend.lib.config import Config
|
||||
from backend.lib.config import Config
|
||||
|
||||
app = FastAPI()
|
||||
templates = Jinja2Templates(directory="src/frontend/templates")
|
||||
|
||||
2
src/frontend/lib/objects.py
vendored
2
src/frontend/lib/objects.py
vendored
@@ -1,7 +1,7 @@
|
||||
"""pyShelf's Frontend Objects."""
|
||||
from subprocess import run
|
||||
from pathlib import Path
|
||||
from ...backend.lib.config import Config
|
||||
from src.backend.lib.config import Config
|
||||
|
||||
|
||||
class JSInterface():
|
||||
|
||||
Reference in New Issue
Block a user