perf.优化python接口的一些调用方式

This commit is contained in:
MistEO
2022-04-03 01:26:05 +08:00
parent 085ae19be1
commit 1999f72089
3 changed files with 7 additions and 6 deletions

View File

@@ -23,7 +23,7 @@ class Asst:
"""
@staticmethod
def load(path: str) -> bool:
def load(path: Union[pathlib.Path, str]) -> bool:
"""
加载 dll 及资源
@@ -32,15 +32,15 @@ class Asst:
"""
if platform.system().lower() == 'windows':
Asst.__libpath = pathlib.Path(path) / 'MeoAssistant.dll'
os.environ["PATH"] += os.pathsep + path
os.environ["PATH"] += os.pathsep + str(path)
Asst.__lib = ctypes.WinDLL(str(Asst.__libpath))
else:
Asst.__libpath = pathlib.Path(path) / 'libMeoAssistant.so'
os.environ['LD_LIBRARY_PATH'] += os.pathsep + path
os.environ['LD_LIBRARY_PATH'] += os.pathsep + str(path)
Asst.__lib = ctypes.CDLL(str(Asst.__libpath))
Asst.__set_lib_properties()
return Asst.__lib.AsstLoadResource(path.encode('utf-8'))
return Asst.__lib.AsstLoadResource(str(path).encode('utf-8'))
def __init__(self, callback: CallBackType = None, arg=None):
"""

View File

@@ -15,7 +15,7 @@ def my_callback(msg, details, arg):
if __name__ == "__main__":
# 请设置为存放 dll 文件及资源的路径
path: str = (pathlib.Path.cwd().parent).__str__()
path = pathlib.Path.cwd().parent
Asst.load(path=path)

View File

@@ -129,7 +129,8 @@ if __name__ == "__main__":
print(m, d, arg)
path: str = (pathlib.Path.cwd().parent).__str__()
# 请设置为存放 dll 文件及资源的路径
path = pathlib.Path.cwd().parent
Asst.load(path)
# 若需要获取详细执行信息,请传入 callback 参数