summaryrefslogtreecommitdiff
path: root/usertools
diff options
context:
space:
mode:
authorHuisong Li <[email protected]>2023-01-10 15:31:45 +0800
committerThomas Monjalon <[email protected]>2023-02-06 08:51:27 +0100
commit2afa9b43a0cb6fd9296a4a5a09b7962664be64fb (patch)
tree4a72ddc872e791edda9141edf413dfa9d0d6df1a /usertools
parentaf13b8711aa43a851d2c12e5d3f8f87dd047307e (diff)
usertools/telemetry: use argparse to get script arguments
The telemetry client script uses argparse module to get input parameter. argparse uses an optional positional arguments for local socket path to keep backward compatibility. Signed-off-by: Huisong Li <[email protected]> Acked-by: Bruce Richardson <[email protected]>
Diffstat (limited to 'usertools')
-rwxr-xr-xusertools/dpdk-telemetry-client.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/usertools/dpdk-telemetry-client.py b/usertools/dpdk-telemetry-client.py
index df41d04fbe..144a8fb5e0 100755
--- a/usertools/dpdk-telemetry-client.py
+++ b/usertools/dpdk-telemetry-client.py
@@ -6,6 +6,7 @@ import socket
import os
import sys
import time
+import argparse
BUFFER_SIZE = 200000
@@ -115,13 +116,12 @@ class Client:
if __name__ == "__main__":
sleep_time = 1
- file_path = ""
- if len(sys.argv) == 2:
- file_path = sys.argv[1]
- else:
- print("Warning - No filepath passed, using default (" + DEFAULT_FP + ").")
- file_path = DEFAULT_FP
+ parser = argparse.ArgumentParser()
+ parser.add_argument('sock_path', nargs='?', default=DEFAULT_FP,
+ help='Provide socket file path connected by legacy client')
+ args = parser.parse_args()
+
client = Client()
- client.getFilepath(file_path)
+ client.getFilepath(args.sock_path)
client.register()
client.interactiveMenu(sleep_time)