feat: migrate exchange and monitor CLI commands to use centralized aitbc package HTTP client
Some checks failed
CLI Tests / test-cli (push) Failing after 2s
Security Scanning / security-scan (push) Successful in 23s

- Replace httpx.Client with aitbc.AITBCHTTPClient in exchange.py list_pairs command
- Migrate monitor.py from httpx to aitbc.AITBCHTTPClient across all commands
- Add aitbc imports: get_logger, AITBCHTTPClient, NetworkError to monitor.py
- Remove httpx import from monitor.py
- Fix indentation in list_pairs command
- Add NetworkError exception handling in list_pairs
- Remove async context managers in favor
This commit is contained in:
aitbc
2026-04-24 23:55:06 +02:00
parent f912fa131d
commit ca07a1c670
2 changed files with 31 additions and 33 deletions

View File

@@ -649,20 +649,13 @@ def list_pairs(ctx, pair: Optional[str], exchange: Optional[str], status: Option
try:
http_client = AITBCHTTPClient(base_url="http://localhost:8001/api/v1", timeout=10)
response = http_client.get(
f"{config.coordinator_url}/v1/exchange/pairs",
params=params,
timeout=10
)
if response.status_code == 200:
pairs = response.json()
success("Trading pairs:")
output(pairs, ctx.obj['output_format'])
else:
error(f"Failed to list trading pairs: {response.status_code}")
except Exception as e:
pairs = http_client.get("/exchange/pairs", params=params)
success("Trading pairs:")
output(pairs, ctx.obj['output_format'])
except NetworkError as e:
error(f"Network error: {e}")
except Exception as e:
error(f"Error: {e}")
@exchange.command()