First Round Async. Much work left to do, dont trust results of hash categorization presently.
This commit is contained in:
+21
-13
@@ -21,8 +21,13 @@
|
||||
#TODO Fix Requirements.txt
|
||||
#TODO Create Generic system_config.json for gitea
|
||||
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
project_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', ".."))
|
||||
sys.path.append(project_root)
|
||||
import asyncio
|
||||
import logging
|
||||
|
||||
import dotenv
|
||||
import urllib3
|
||||
@@ -30,21 +35,26 @@ import urllib3
|
||||
import utils.menus as menus
|
||||
from services.API import AirlockAPIWrapper
|
||||
from services.security import getAPI
|
||||
from services.TaskQueue import AsyncTaskQueue
|
||||
from utils.setup import setup
|
||||
|
||||
urllib3.disable_warnings(
|
||||
urllib3.exceptions.InsecureRequestWarning
|
||||
)
|
||||
|
||||
def main():
|
||||
|
||||
async def main():
|
||||
|
||||
#Determine working directory, setup directory, configure logging, sent env, get API and URL if not already stored
|
||||
|
||||
working_dir = setup()
|
||||
working_dir = await setup()
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.debug("🔍 Logging test: this should appear in both console and file.")
|
||||
dotenv.load_dotenv(dotenv_path=working_dir / ".env")
|
||||
|
||||
queue = AsyncTaskQueue(worker_count = 3)
|
||||
await queue.start_workers()
|
||||
|
||||
|
||||
try:
|
||||
url = os.getenv("URL")
|
||||
username = os.getenv("USERNAME")
|
||||
@@ -61,15 +71,13 @@ def main():
|
||||
logger.error(f"Configuration error: {e}", exc_info=True)
|
||||
raise
|
||||
|
||||
|
||||
api = AirlockAPIWrapper(
|
||||
base_url=str(os.getenv("URL")),
|
||||
api_key = getAPI(username, "AirlockTools"),
|
||||
)
|
||||
|
||||
|
||||
menus.menu_main(api)
|
||||
if username:
|
||||
api = AirlockAPIWrapper(
|
||||
base_url=str(os.getenv("URL")),
|
||||
api_key = await getAPI(username, "AirlockTools"), # pyright: ignore[reportArgumentType]
|
||||
)
|
||||
await menus.menu_main(api, queue)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user