go_api_w_raw.py 1.5 KB

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