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:
23
pyShelf.py
23
pyShelf.py
@@ -1,14 +1,29 @@
|
||||
#!/usr/bin/env python3
|
||||
import asyncio
|
||||
import websockets
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from loguru import logger
|
||||
from src.backend.lib.config import Config
|
||||
from src.backend.pyShelf_ScanLibrary import execute_scan
|
||||
from src.backend.pyShelf_MakeCollections import MakeCollections
|
||||
|
||||
|
||||
root = Path.cwd()
|
||||
config = Config(root)
|
||||
PRG_PATH = Path.cwd().__str__()
|
||||
sys.path.insert(0, PRG_PATH)
|
||||
|
||||
tx = None
|
||||
|
||||
|
||||
async def echo(websocket, path):
|
||||
async def runImport():
|
||||
execute_scan(PRG_PATH)
|
||||
MakeCollections(PRG_PATH)
|
||||
return "Import Complete"
|
||||
|
||||
|
||||
async def socketio(websocket, path):
|
||||
async for message in websocket:
|
||||
if message == "import":
|
||||
print("message from Con1 >> {}".format(message))
|
||||
@@ -22,6 +37,10 @@ async def echo(websocket, path):
|
||||
elif message == "importBooks":
|
||||
print("<<[{} cmd rcvd]\n Starting import".format(message))
|
||||
tx = "Starting Import . . ."
|
||||
await websocket.send(tx)
|
||||
await runImport()
|
||||
tx = "complete"
|
||||
|
||||
await websocket.send(tx)
|
||||
|
||||
|
||||
@@ -30,7 +49,7 @@ def pong(message):
|
||||
return "pong"
|
||||
|
||||
|
||||
start_server = websockets.serve(echo, "127.0.0.1", 1337)
|
||||
start_server = websockets.serve(socketio, "127.0.0.1", 1337)
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(start_server)
|
||||
asyncio.get_event_loop().run_forever()
|
||||
|
||||
Reference in New Issue
Block a user