From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH 2/2] usertools/dpdk-telemetry-client: correct script formatting
Date: Fri, 17 Oct 2025 14:56:22 +0100 [thread overview]
Message-ID: <20251017135622.1152341-3-bruce.richardson@intel.com> (raw)
In-Reply-To: <20251017135622.1152341-1-bruce.richardson@intel.com>
Auto-format the dpdk-telemetry-client script using "black" tool, to
ensure it meets default DPDK python formatting style.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
usertools/dpdk-telemetry-client.py | 49 +++++++++++++++++-------------
1 file changed, 28 insertions(+), 21 deletions(-)
diff --git a/usertools/dpdk-telemetry-client.py b/usertools/dpdk-telemetry-client.py
index e3bb1c9ee0..f65d2e0be4 100755
--- a/usertools/dpdk-telemetry-client.py
+++ b/usertools/dpdk-telemetry-client.py
@@ -9,13 +9,13 @@
BUFFER_SIZE = 200000
-METRICS_REQ = "{\"action\":0,\"command\":\"ports_all_stat_values\",\"data\":null}"
-API_REG = "{\"action\":1,\"command\":\"clients\",\"data\":{\"client_path\":\""
-API_UNREG = "{\"action\":2,\"command\":\"clients\",\"data\":{\"client_path\":\""
-GLOBAL_METRICS_REQ = "{\"action\":0,\"command\":\"global_stat_values\",\"data\":null}"
+METRICS_REQ = '{"action":0,"command":"ports_all_stat_values","data":null}'
+API_REG = '{"action":1,"command":"clients","data":{"client_path":"'
+API_UNREG = '{"action":2,"command":"clients","data":{"client_path":"'
+GLOBAL_METRICS_REQ = '{"action":0,"command":"global_stat_values","data":null}'
DEFAULT_FP = "/var/run/dpdk/default_client"
-DEFAULT_PREFIX = 'rte'
-RUNTIME_SOCKET_NAME = 'telemetry'
+DEFAULT_PREFIX = "rte"
+RUNTIME_SOCKET_NAME = "telemetry"
class Socket:
@@ -56,8 +56,7 @@ def getFilepath(self, file_path):
self.file_path = file_path
def setRunpath(self, file_prefix):
- self.run_path = os.path.join(get_dpdk_runtime_dir(file_prefix),
- RUNTIME_SOCKET_NAME)
+ self.run_path = os.path.join(get_dpdk_runtime_dir(file_prefix), RUNTIME_SOCKET_NAME)
def register(self):
# Connects a client to DPDK-instance
@@ -69,7 +68,7 @@ def register(self):
print("Error - Socket binding error: " + str(msg) + "\n")
self.socket.recv_fd.settimeout(2)
self.socket.send_fd.connect(self.run_path)
- JSON = (API_REG + self.file_path + "\"}}")
+ JSON = API_REG + self.file_path + '"}}'
self.socket.send_fd.sendall(JSON.encode())
self.socket.recv_fd.listen(1)
@@ -77,7 +76,7 @@ def register(self):
def unregister(self):
# Unregister a given client
- self.socket.client_fd.send((API_UNREG + self.file_path + "\"}}").encode())
+ self.socket.client_fd.send((API_UNREG + self.file_path + '"}}').encode())
self.socket.client_fd.close()
def requestMetrics(self):
@@ -133,25 +132,33 @@ def interactiveMenu(self, sleep_time):
def get_dpdk_runtime_dir(fp):
- """ Using the same logic as in DPDK's EAL, get the DPDK runtime directory
- based on the file-prefix and user """
- run_dir = os.environ.get('RUNTIME_DIRECTORY')
+ """Using the same logic as in DPDK's EAL, get the DPDK runtime directory
+ based on the file-prefix and user"""
+ run_dir = os.environ.get("RUNTIME_DIRECTORY")
if not run_dir:
- if (os.getuid() == 0):
- run_dir = '/var/run'
+ if os.getuid() == 0:
+ run_dir = "/var/run"
else:
- run_dir = os.environ.get('XDG_RUNTIME_DIR', '/tmp')
- return os.path.join(run_dir, 'dpdk', fp)
+ run_dir = os.environ.get("XDG_RUNTIME_DIR", "/tmp")
+ return os.path.join(run_dir, "dpdk", fp)
if __name__ == "__main__":
sleep_time = 1
parser = argparse.ArgumentParser()
- parser.add_argument('-f', '--file-prefix', default=DEFAULT_PREFIX,
- help='Provide file-prefix for DPDK runtime directory')
- parser.add_argument('sock_path', nargs='?', default=DEFAULT_FP,
- help='Provide socket file path connected by legacy client')
+ parser.add_argument(
+ "-f",
+ "--file-prefix",
+ default=DEFAULT_PREFIX,
+ help="Provide file-prefix for DPDK runtime directory",
+ )
+ parser.add_argument(
+ "sock_path",
+ nargs="?",
+ default=DEFAULT_FP,
+ help="Provide socket file path connected by legacy client",
+ )
args = parser.parse_args()
client = Client()
--
2.48.1
next prev parent reply other threads:[~2025-10-17 13:56 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-17 13:56 [PATCH 0/2] format telemetry scripts using black Bruce Richardson
2025-10-17 13:56 ` [PATCH 1/2] usertools/dpdk-telemetry: correct script formatting Bruce Richardson
2025-10-17 13:56 ` Bruce Richardson [this message]
2025-10-17 14:19 ` [PATCH v2 0/2] format telemetry scripts using black Bruce Richardson
2025-10-17 14:19 ` [PATCH v2 1/2] usertools/dpdk-telemetry.py: correct script formatting Bruce Richardson
2025-10-17 14:19 ` [PATCH v2 2/2] usertools/dpdk-telemetry-client: " Bruce Richardson
2025-10-17 15:08 ` [PATCH 0/2] format telemetry scripts using black Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251017135622.1152341-3-bruce.richardson@intel.com \
--to=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).