entry.py 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. """
  4. 共享库入口文件 (.so / .pyd)
  5. 暴露 Python 级别的函数供外部(如 Node.js / Vue3)调用。
  6. """
  7. import json
  8. import base64
  9. from license_checker import verify_license
  10. # 延迟导入核心业务逻辑,确保先验证 License
  11. def _check_auth():
  12. if not verify_license():
  13. raise PermissionError("License verification failed. Please provide a valid license.lic and public_key.pem file.")
  14. def get_path():
  15. """对应原 api_test.py 中的 getpath"""
  16. _check_auth()
  17. import data_clean as dc
  18. return_path = str(dc.result_main())
  19. return json.dumps({'obj': return_path}, ensure_ascii=False)
  20. def load_data(b64_json_data):
  21. """对应原 api_test.py 中的 loaddata"""
  22. _check_auth()
  23. import data_clean as dc
  24. data = json.loads(base64.b64decode(b64_json_data).decode("utf-8"))
  25. return_list = dc.data_analyse(data)
  26. return json.dumps(return_list, ensure_ascii=False)
  27. def history_data(b64_json_data):
  28. """对应原 api_test.py 中的 historydata"""
  29. _check_auth()
  30. import data_clean as dc
  31. data = json.loads(base64.b64decode(b64_json_data).decode("utf-8"))
  32. return_list = dc.history_data(data)
  33. return json.dumps(return_list, ensure_ascii=False)
  34. def delete_data(b64_json_data):
  35. """对应原 api_test.py 中的 deletedata"""
  36. _check_auth()
  37. import data_clean as dc
  38. data = json.loads(base64.b64decode(b64_json_data).decode("utf-8"))
  39. return_path = dc.delete_data(data)
  40. return json.dumps(return_path, ensure_ascii=False)