go_api_w_watch_list.py 1.4 KB

12345678910111213141516171819202122232425
  1. from .tool.func import *
  2. def api_w_watch_list(db_set, name = 'Test', do_type = 'watch_list', num = 1):
  3. with get_db_connect() as conn:
  4. other_set = {}
  5. other_set["name"] = name
  6. other_set["do_type"] = do_type
  7. other_set["ip"] = ip_check()
  8. other_set["num"] = str(num)
  9. other_set = json.dumps(other_set)
  10. if platform.system() == 'Linux':
  11. if platform.machine() in ["AMD64", "x86_64"]:
  12. data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.amd64.bin"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
  13. else:
  14. data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.arm64.bin"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
  15. else:
  16. if platform.machine() in ["AMD64", "x86_64"]:
  17. data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.amd64.exe"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
  18. else:
  19. data = subprocess.Popen([os.path.join(".", "route_go", "bin", "main.arm64.exe"), sys._getframe().f_code.co_name, db_set, other_set], stdout = subprocess.PIPE).communicate()[0]
  20. data = data.decode('utf8')
  21. return flask.Response(response = data, status = 200, mimetype = 'application/json')