Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: replace throwing exception with returning error in Python #456

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
7264ea5
feat: replace throwing exception with returning error in Python
sunxilin Dec 23, 2024
5aba07e
Merge branch 'main' into 454-replace-throwing-exception-with-returnin…
sunxilin Dec 23, 2024
1282673
chore: python test case
sunxilin Dec 23, 2024
9cee6a3
Merge branch 'main' into 454-replace-throwing-exception-with-returnin…
sunxilin Dec 23, 2024
770e1d4
Merge branch 'main' into 454-replace-throwing-exception-with-returnin…
sunxilin Dec 24, 2024
8f56510
Merge branch 'main' into 454-replace-throwing-exception-with-returnin…
halajohn Dec 24, 2024
b384f83
Merge branch 'main' into 454-replace-throwing-exception-with-returnin…
sunxilin Dec 25, 2024
9ccb9d6
fix: python binding
sunxilin Dec 25, 2024
786b2bc
Merge branch 'main' into 454-replace-throwing-exception-with-returnin…
sunxilin Dec 26, 2024
e131605
refactor: make tenEnv and tenEnvAsync inherited from tenEnvBase class
sunxilin Dec 26, 2024
96065e6
Merge branch 'main' into 454-replace-throwing-exception-with-returnin…
halajohn Dec 26, 2024
53decd3
fix: refine some codes
halajohn Dec 26, 2024
089c868
fix: refine some codes
halajohn Dec 26, 2024
52d5fb8
fix: refine some codes
halajohn Dec 26, 2024
bd9a335
fix: refine some codes
halajohn Dec 26, 2024
297580e
fix: fix return type of send/return_msg in Python
sunxilin Dec 26, 2024
1249fb0
fix: fix return type of send/return_msg in Python
sunxilin Dec 26, 2024
6e47ee0
fix: refine some codes
halajohn Dec 26, 2024
6e4d591
fix: refine some codes
halajohn Dec 26, 2024
6b9b8fa
fix: refine some codes
halajohn Dec 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions build/common/rust/cargo_build_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import json
import sys
import os
from typing import Optional
from build.scripts import cmd_exec, fs_utils, timestamp_proxy


Expand All @@ -21,8 +22,8 @@ def __init__(self):
self.env: list[str]
self.log_level: int
self.test_output_dir: str
self.tg_timestamp_proxy_file: str | None = None
self.integration_test_output_name: str | None = None
self.tg_timestamp_proxy_file: Optional[str] = None
self.integration_test_output_name: Optional[str] = None


def get_crate_test_output_name(log_level: int) -> str:
Expand Down
3 changes: 2 additions & 1 deletion build/common/rust/cargo_clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import argparse
import sys
import os
from typing import Optional
from build.scripts import cmd_exec, timestamp_proxy


Expand All @@ -17,7 +18,7 @@ def __init__(self):
self.target_path: str
self.target: str
self.log_level: int
self.tg_timestamp_proxy_file: str | None = None
self.tg_timestamp_proxy_file: Optional[str] = None


if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion build/common/rust/rust_gen_cargo_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import shutil
import sys
import os
from typing import Optional
from build.scripts import timestamp_proxy

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
Expand Down Expand Up @@ -81,7 +82,7 @@ def __init__(self):
self.target: str
self.target_os: str
self.target_arch: str
self.tg_timestamp_proxy_file: str | None = None
self.tg_timestamp_proxy_file: Optional[str] = None
self.enable_asan: bool
self.action: str
self.disable_incremental: bool = False
Expand Down
3 changes: 2 additions & 1 deletion build/common/scripts/get_lib_name_from_cmake_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#
import argparse
import os
from typing import Optional


class ArgumentInfo(argparse.Namespace):
Expand All @@ -26,7 +27,7 @@ def is_candidate_libname(self, lib_path: str) -> bool:
return False
return True

def get_link_lib_name(self, lib_path: str) -> str | None:
def get_link_lib_name(self, lib_path: str) -> Optional[str]:
lib_basename = os.path.basename(lib_path)
if self.args.target_os == "win":
return lib_basename
Expand Down
5 changes: 3 additions & 2 deletions build/ten_runtime/feature/combine_static_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import sys
import os
import shutil
from build.scripts import cmd_exec
from typing import Optional
from dotenv import dotenv_values
from io import StringIO
from build.scripts import cmd_exec


class ArgumentInfo(argparse.Namespace):
Expand Down Expand Up @@ -41,7 +42,7 @@ def ar_create(target_library: str, target_path: str, log_level: int) -> None:
raise Exception("Failed to create static library.")


def read_path_from_env_file(env_file: str) -> str | None:
def read_path_from_env_file(env_file: str) -> Optional[str]:
with open(env_file, "rb") as f:
for line in f:
# NUL character.
Expand Down
5 changes: 3 additions & 2 deletions build/ten_runtime/feature/publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
import argparse
import re
import sys
from typing import Optional
import subprocess
from build.scripts import cmd_exec, touch
from common.scripts import delete_files
import subprocess


class ArgumentInfo(argparse.Namespace):
Expand All @@ -24,7 +25,7 @@ def __init__(self):
self.cpu: str


def extract_publish_path(text: str) -> str | None:
def extract_publish_path(text: str) -> Optional[str]:
pattern = r'Publish to "(.+?)"'
match = re.search(pattern, text)
return match.group(1) if match is not None else None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,41 @@ TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_set_property_float(
TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_init_property_from_json(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_get_property_to_json_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_set_property_from_json_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_is_property_exist_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_get_property_int_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_set_property_int_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_get_property_string_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_set_property_string_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_get_property_bool_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_set_property_bool_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_get_property_float_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_set_property_float_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_init_property_from_json_async(
PyObject *self, PyObject *args);

TEN_RUNTIME_PRIVATE_API PyObject *ten_py_ten_env_log(PyObject *self,
PyObject *args);
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import sys
import importlib.util
from glob import glob
from typing import Callable, Dict, Type
from typing import Callable, Dict, Type, Optional

from .addon import Addon
from libten_runtime_python import _register_addon_as_extension

Expand Down Expand Up @@ -133,7 +134,7 @@ def _find_app_base_dir():
)


def register_addon_as_extension(name: str, base_dir: str | None = None):
def register_addon_as_extension(name: str, base_dir: Optional[str] = None):
def decorator(cls: Type[Addon]) -> Type[Addon]:
# Resolve base_dir.
if base_dir is None:
Expand Down
Loading
Loading