forked from TEN-framework/ten-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
68 lines (56 loc) · 1.89 KB
/
Copy pathmain.py
File metadata and controls
68 lines (56 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
#
# Agora Real Time Engagement
# Created by Wei Hu in 2024-05.
# Copyright (c) 2024 Agora IO. All rights reserved.
#
#
from glob import glob
import importlib.util
import os
import argparse
from os.path import dirname
def log(msg):
print("[PYTHON] {}".format(msg))
def process_args():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
"--manifest", help="The absolute path of manifest.json"
)
return parser.parse_args()
if __name__ == "__main__":
args = process_args()
basedir = dirname(__file__)
log("app init")
for module in glob(os.path.join(basedir, "addon/extension/*")):
if os.path.isdir(module):
module_name = os.path.basename(module)
spec = importlib.util.find_spec(
"addon.extension.{}".format(module_name)
)
if spec is not None:
mod = importlib.import_module(
"addon.extension.{}".format(module_name)
)
print("imported module: {}".format(module_name))
from rte_runtime_python import App, MetadataType
class TestApp(App):
def on_init(self, rte, manifest, property):
log("app on_init")
# Using the default manifest.json if not specified.
if self.manifest_path:
log("set manifest: {}".format(self.manifest_path))
manifest.set(MetadataType.JSON_FILENAME, self.manifest_path)
rte.on_init_done(manifest, property)
def on_deinit(self, rte) -> None:
log("app on_deinit")
rte.on_deinit_done()
def set_manifest_path(self, manifest_path):
self.manifest_path = manifest_path
app = TestApp()
app.set_manifest_path(args.manifest)
log("app created")
app.run(False)
log("app run done")