dell / dell/iDRAC-Telemetry-Scripting

create_sse_subscription function is bugged - it will truncate events

オープン
#12 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
23
フォーク
11
PR マージ指標
30日以内にマージされた PR はありません

説明

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 = "

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

create_sse_subscription を見つけ、現在の requests ベースのストリーミングが SSE の行とイベント境界をどのように処理しているかを調査します。そのアプローチを SSE リスナーに置き換え、完全な SSE イベントが切り詰められることなく受信され、出力されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。