Commit e1e10718 by Oleksandr Barabash

teams app zip generator fixed

parent 3940f573
......@@ -23,6 +23,7 @@ from entities.json.notification import Notification
from utils.cosmos_client import ItemNotFound
from utils.json_func import json_loads
from utils.log import Log
from utils.teams_app_generator import TeamsAppGenerator
app_config = AppConfig()
......@@ -174,9 +175,10 @@ async def v1_health_check(_request: Request) -> Response:
raise
async def get_app_zip(request: Request) -> FileResponse:
async def get_app_zip(_request: Request) -> FileResponse:
""" Get zip file """
Log.i(TAG, "v1_health_check::ok")
await TeamsAppGenerator.generate_zip()
return FileResponse(path=TeamsAppConfig.zip_file)
......@@ -203,7 +205,7 @@ APP.router.add_get("/api/v1/notification/{notification_id}",
v1_get_notification)
APP.router.add_get("/api/v1/initiations/{notification_id}", v1_get_initiations)
APP.router.add_get("/api/v1/health-check", v1_health_check)
APP.router.add_get("/app.zip", get_app_zip)
APP.router.add_get("/{}".format(TeamsAppConfig.zip_name), get_app_zip)
BOT.add_web_app(APP)
......
......@@ -18,7 +18,8 @@ class TeamsAppConfig:
manifest = os.path.join(teams_app_items, "manifest,json")
image_192x192 = os.path.join(teams_app_items, "color_192x192.png")
image_32x32 = os.path.join(teams_app_items, "outline_32x32.png")
zip_file = os.path.join(teams_app_items, "app.zip")
zip_name = "app.zip"
zip_file = os.path.join(teams_app_items, zip_name)
class TaskModuleConfig:
......
......@@ -31,9 +31,9 @@ class AzureKeyVaultClient:
self.secret_client = SecretClient(vault_url=self.key_vault_uri,
credential=self.credential)
async def execute_blocking(self, bl, *args):
def execute_blocking(self, bl, *args):
""" Execute blocking code """
return await self.io_loop.run_in_executor(self.executor, bl, *args)
return self.io_loop.run_in_executor(self.executor, bl, *args)
def set_secret(self, name: str, value: str) -> Awaitable["KeyVaultSecret"]:
""" Async set secret """
......
""" Teams App Generator """
import asyncio
import json
import os
from zipfile import ZipFile, ZIP_DEFLATED
......@@ -87,8 +88,8 @@ class TeamsAppGenerator:
return TeamsAppConfig.manifest
@staticmethod
def get_zip():
""" Generate the app """
def generate_zip_bl():
""" Generate zip blocking """
TeamsAppGenerator.gen_manifest()
with ZipFile(TeamsAppConfig.zip_file, "w", ZIP_DEFLATED) as zip_file:
for file in [TeamsAppConfig.manifest,
......@@ -96,3 +97,9 @@ class TeamsAppGenerator:
TeamsAppConfig.image_192x192]:
file_name = os.path.basename(file)
zip_file.write(file, arcname=file_name)
@staticmethod
async def generate_zip():
""" Generate the app """
io_loop = asyncio.get_event_loop()
await io_loop.run_in_executor(None, TeamsAppGenerator.generate_zip_bl)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment