Fix lint: wrap long line in diagnose.py; make demo scripts flake8-clean
Lint / Python (flake8) (push) Successful in 1m11s
Lint / JS (eslint) (push) Successful in 14s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Successful in 49s
Test / Python Tests (pytest) (push) Successful in 1m0s
Lint / Deploy (push) Successful in 3s
Lint / Python (flake8) (push) Successful in 1m11s
Lint / JS (eslint) (push) Successful in 14s
Lint / Notify on failure (push) Skipped
Security / Python Security (bandit) (push) Successful in 49s
Test / Python Tests (pytest) (push) Successful in 1m0s
Lint / Deploy (push) Successful in 3s
This commit is contained in:
+41
-23
@@ -1,6 +1,10 @@
|
||||
"""Minimal stand-in for the PULSE internal API, returning canned diagnostics output (fictional data)."""
|
||||
|
||||
# flake8: noqa: E501 (demo data and canned output contain long literal lines)
|
||||
|
||||
import json
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
|
||||
CANNED = """=== carrier ===
|
||||
1
|
||||
=== operstate ===
|
||||
@@ -22,14 +26,14 @@ rx_missed_errors:0
|
||||
6
|
||||
=== ethtool ===
|
||||
Settings for enp5s0:
|
||||
Supported ports: [ FIBRE ]
|
||||
Supported link modes: 10000baseT/Full
|
||||
Speed: 10000Mb/s
|
||||
Duplex: Full
|
||||
Port: FIBRE
|
||||
PHYAD: 0
|
||||
Auto-negotiation: off
|
||||
Link detected: yes
|
||||
Supported ports: [ FIBRE ]
|
||||
Supported link modes: 10000baseT/Full
|
||||
Speed: 10000Mb/s
|
||||
Duplex: Full
|
||||
Port: FIBRE
|
||||
PHYAD: 0
|
||||
Auto-negotiation: off
|
||||
Link detected: yes
|
||||
=== ethtool_driver ===
|
||||
driver: ixgbe
|
||||
version: 6.8.12-4-pve
|
||||
@@ -65,16 +69,16 @@ NIC statistics:
|
||||
tx_flow_control_xon: 0
|
||||
rx_flow_control_xon: 0
|
||||
=== ethtool_dom ===
|
||||
Identifier : 0x03 (SFP)
|
||||
Connector : 0x07 (LC)
|
||||
Vendor name : FS
|
||||
Vendor PN : SFP-10GSR-85
|
||||
Laser wavelength : 850nm
|
||||
Laser bias current : 6.100 mA
|
||||
Laser output power : 0.5530 mW / -2.57 dBm
|
||||
Receiver signal average optical power : 0.0120 mW / -19.21 dBm
|
||||
Module temperature : 47.50 degrees C / 117.50 degrees F
|
||||
Module voltage : 3.3120 V
|
||||
Identifier : 0x03 (SFP)
|
||||
Connector : 0x07 (LC)
|
||||
Vendor name : FS
|
||||
Vendor PN : SFP-10GSR-85
|
||||
Laser wavelength : 850nm
|
||||
Laser bias current : 6.100 mA
|
||||
Laser output power : 0.5530 mW / -2.57 dBm
|
||||
Receiver signal average optical power : 0.0120 mW / -19.21 dBm
|
||||
Module temperature : 47.50 degrees C / 117.50 degrees F
|
||||
Module voltage : 3.3120 V
|
||||
=== ip_link ===
|
||||
5: enp5s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 9000 qdisc mq master vmbr1 state UP mode DEFAULT group default qlen 1000
|
||||
link/ether 02:00:5e:10:00:05 brd ff:ff:ff:ff:ff:ff
|
||||
@@ -104,12 +108,26 @@ Interface: enp5s0, via: LLDP, RID: 1, Time: 12 days, 03:11:42
|
||||
PortID: ifname Port 4
|
||||
=== end ===
|
||||
"""
|
||||
|
||||
|
||||
class H(BaseHTTPRequestHandler):
|
||||
def _send(self, obj, code=200):
|
||||
b = json.dumps(obj).encode(); self.send_response(code); self.send_header('Content-Type', 'application/json'); self.send_header('Content-Length', str(len(b))); self.end_headers(); self.wfile.write(b)
|
||||
b = json.dumps(obj).encode()
|
||||
self.send_response(code)
|
||||
self.send_header("Content-Type", "application/json")
|
||||
self.send_header("Content-Length", str(len(b)))
|
||||
self.end_headers()
|
||||
self.wfile.write(b)
|
||||
|
||||
def do_POST(self):
|
||||
self.rfile.read(int(self.headers.get('Content-Length', 0) or 0)); self._send({'execution_id': 'demo-exec-0001'})
|
||||
self.rfile.read(int(self.headers.get("Content-Length", 0) or 0))
|
||||
self._send({"execution_id": "demo-exec-0001"})
|
||||
|
||||
def do_GET(self):
|
||||
self._send({'status': 'completed', 'logs': [{'action': 'command_result', 'stdout': CANNED}]})
|
||||
def log_message(self, *a): pass
|
||||
HTTPServer(('127.0.0.1', 8650), H).serve_forever()
|
||||
self._send({"status": "completed", "logs": [{"action": "command_result", "stdout": CANNED}]})
|
||||
|
||||
def log_message(self, *a):
|
||||
pass
|
||||
|
||||
|
||||
HTTPServer(("127.0.0.1", 8650), H).serve_forever()
|
||||
|
||||
Reference in New Issue
Block a user