Advertisement
jim_boz

Untitled

Mar 17th, 2023
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. def oapi_version():
  2.  
  3.     logging.info("Checking openapi version on VM {}".format(vm))
  4.  
  5.     try:
  6.  
  7.         r = requests.get(f"https://{vm}/socket.io/1/")
  8.         token = r.content.decode().split(":")[0]
  9.  
  10.         r1 = requests.get(f"https://{vm}/socket.io/1/xhr-polling/{token}")
  11.         r2 = requests.post(f"https://{vm}/socket.io/1/xhr-polling/{token}", data="3:::{\"ID\":400}")
  12.         r3 = requests.get(f"https://{vm}/socket.io/1/xhr-polling/{token}")
  13.         logging.info(r3.content.decode().replace("3:::", ""))
  14.         oapi_response = json.loads(r3.content.decode().replace("3:::", ""))
  15.  
  16.     except requests.exceptions.RequestException as e:
  17.         logging.error("Unable to check OpenApi service version - error text {}".format(e))
  18.         oapi_response = {"moduleVersions": ["unable to detect"]}
  19.  
  20.     apps_version_result.update({"openapi": oapi_response["moduleVersions"]})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement