Import Books now working in ui, Working on logging.

This commit is contained in:
Raelon Masters
2020-08-15 01:09:28 -04:00
parent 3f99c15038
commit 5429b7ee00
9 changed files with 70 additions and 10 deletions

View File

@@ -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()