import all
This commit is contained in:
commit
881baaa1ed
25 files changed
+1779
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import asyncio
|
||||
import aiohttp
|
||||
from uuid import uuid4
|
||||
from base64 import b64encode
|
||||
import os
|
||||
|
||||
|
||||
async def idp_request(cmd: str):
|
||||
headers = {
|
||||
"Idempotency-Key": f"{uuid4()}",
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": "Kopling/0.12",
|
||||
}
|
||||
print(f"[@DEBUG] Idempotency-Key: {headers['Idempotency-Key']}")
|
||||
|
||||
enc_cmd = b64encode(f"{cmd}".encode("utf-8")).decode("utf-8")
|
||||
print("[@DEBUG] Encoded command:", enc_cmd)
|
||||
print("[@DEBUG] Sending request..")
|
||||
try:
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.post(
|
||||
"http://localhost:7432", # Added http:// protocol
|
||||
headers=headers,
|
||||
json={"CMD": enc_cmd}, # Changed to json instead of data
|
||||
) as resp:
|
||||
print(f"[@DEBUG] Response status: {resp.status}")
|
||||
print(f"[@DEBUG] Response body: {await resp.text()}")
|
||||
except Exception as e:
|
||||
print(f"\nRequest failed: {e}")
|
||||
os._exit(-1)
|
||||
|
||||
|
||||
async def main():
|
||||
# Await the task instead of just creating it
|
||||
await idp_request("RUNUPDATE")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in new issue
Block a user