issue 26: now check if the response from sxc is test result if not it will retry

This commit is contained in:
SovereigntyIsNotFreedom 2025-05-21 15:12:02 +01:00
parent b653171e84
commit f394e8ef2f
2 changed files with 55 additions and 53 deletions

View file

@ -1,9 +1,12 @@
import random
import re
import os
import requests
from PIL import Image
import json
#from SimpleX.utils import IsUrlValid
import urllib.parse
from websockets.sync.client import connect
PURPLE = '\033[35;40m'
@ -362,4 +365,21 @@ def IsSimpleXUrlValid(url:str)->bool:
return False
return True
def send_server_checks(url:str) -> ():
"""
Sends requests to sxc websocket and retuns
response, response type and testFailure or None.
"""
with connect(f"ws://localhost:3030") as websocket:
query = f"/_server test 1 {url}"
command = {
'corrId': f"id{random.randint(0,999999)}",
'cmd': query,
}
websocket.send(json.dumps(command))
message = websocket.recv()
response = json.loads(message)
resp_type = response["resp"]["type"]
failed_response = response['resp'].get('testFailure')
return (response, resp_type, failed_response)