dell / dell/iDRAC-Telemetry-Scripting

create_sse_subscription function is bugged - it will truncate events

Abierto
#12 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
23
Forks
11
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I haven't gone back to fix the code but I realized today that the current code will truncate events instead of printing the full SSE event. My hacked solution to keep moving is below:

```python
import requests
import json

def enable_sse_client(idrac_ip, idrac_username, idrac_password):
"""
Enables an SSE client with the given arguments and outputs received event data.

:param idrac_ip: IP address of the target iDRAC
:param idrac_username: Username of the target iDRAC
:param idrac_password: Password of the target iDRAC
"""
url = "https://%s/redfish/v1/SSE?$filter=EventFormatType eq MetricReport" % idrac_ip
headers = {'content-type': 'application/json'}
verify = False
auth = (idrac_username, idrac_password)

print("- INFO: Starting SSE client, this may take a few seconds")
response = requests.get(url, headers=headers, verify=verify, auth=auth, stream=True)

skip_first_event = True
for line in response.iter_lines(decode_unicode=True):
if line:
if skip_first_event:
skip_first_event = False
continue

if line.startswith("data:"):
try:
json_data = line[len("data:"):].strip()
parsed_data = json.loads(json_data)
formatted_data = json.dumps(parsed_data, indent=4)
print("Received SSE event:")
print(formatted_data)
print()
except json.JSONDecodeError:
print("Error decoding JSON data from SSE event. Skipping this line.")
print("Received line:", line)
print()

# Example usage
idrac_ip = ""
idrac_username = "root"
idrac_password = "

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Localiza create_sse_subscription e inspecciona cómo el streaming actual basado en requests gestiona las líneas SSE y los límites de los eventos. Sustituye ese enfoque por un listener de SSE y verifica después que los eventos SSE completos se reciben y se imprimen sin truncarse.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
api
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.