From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5EF4D42388; Mon, 9 Jan 2023 18:07:42 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4ABFD40689; Mon, 9 Jan 2023 18:07:42 +0100 (CET) Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by mails.dpdk.org (Postfix) with ESMTP id 0A89340150 for ; Mon, 9 Jan 2023 18:07:41 +0100 (CET) Received: by mail-pf1-f181.google.com with SMTP id g20so6633596pfb.3 for ; Mon, 09 Jan 2023 09:07:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TYSCJaMFd+AkV3VV1V+iQHcOXYZrnJ61hkEpMDrn79E=; b=Y2IC+LAs9Zqisz3HfvJTdREdPtbUXBrYk4P+yTqqTQOjTWeyltJzLkKQtlXsHSh+b6 gxR/hRZ9mH/TKX4aF5zZtmJBronLJdkOWaTxzXS87whAv4D15iCIJACQVFrOyYDdoGJp oC6L0689sfy0itY7QYjGz+p31XswloPnsie+zY4cbgJZrccR64IP/0Ms0QzAIucvfn5Q UaDpQ9n+AfRAbPK1VF7+fYXOkgvTqzfZ5Dom8VOxCR7H+DNONzZft0FqdEdxSa6WQFPI GiFqu+jLM+EGZPQrDYDBbnJV0Eg2sVXamDoYPA7Qkk3TkVi5xHUsSdALyDeBRZAtvWxI i7GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TYSCJaMFd+AkV3VV1V+iQHcOXYZrnJ61hkEpMDrn79E=; b=EunOdbeEM8Ja40wqClEK7+JoRJfUjVGVOdn1agsi2Lw2mKWqK18uFL0p3kFV/t4wDh HN97aM5RfwybjTdjhQX6n7TPUwq8bgQIRq4DWDcUF/6z35BOJS6uP/sayWZT9Iwa6C2k zKKHK6csDGfYid19OIs78y2+3i5CgSgliH0Vc8w2ikIGNAMTlsBdYXkjOOdOM4G/XUZl 7ld2eu1LUStRIFD7Vw4c4hQNPFuYRggFf5F4kMjTyNwlcrTRZE1BNclE3CNJGw5LE8Sd uGdrD78IvlBSqCiAZ2zZEle+7b7h6F6ZqJapi+cscoZ3Wau/Jm79qGu7h0XRS1C62dFG 7hjQ== X-Gm-Message-State: AFqh2kqsz/3iQge8XfIev3ROzAU8KS4BUDYXuh1oGdthop4f27r7/jRA tXCssizFQP3zF4WBb+lwXYCauqn18tlqdRA+ X-Google-Smtp-Source: AMrXdXst2BYFwAmQGS+I0JVtaOy/+/QMssjI63MFfLxoId9DnZvARzuL1N//JAPjHNlLrY7+WlJ3rA== X-Received: by 2002:a62:ee0e:0:b0:578:f6f:efab with SMTP id e14-20020a62ee0e000000b005780f6fefabmr70944587pfi.11.1673284059671; Mon, 09 Jan 2023 09:07:39 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id i24-20020a056a00225800b00583698ba91dsm6323768pfu.40.2023.01.09.09.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Jan 2023 09:07:39 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Subject: [PATCH] usertools: fix python warnings Date: Mon, 9 Jan 2023 09:07:38 -0800 Message-Id: <20230109170738.21047-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230109065547.8819-1-lihuisong@huawei.com> References: <20230109065547.8819-1-lihuisong@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This fixes most of the flake8 style warnings on the telemetry script. Signed-off-by: Stephen Hemminger --- usertools/dpdk-telemetry-client.py | 37 +++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/usertools/dpdk-telemetry-client.py b/usertools/dpdk-telemetry-client.py index f1561af4c6b2..8e8efc151218 100755 --- a/usertools/dpdk-telemetry-client.py +++ b/usertools/dpdk-telemetry-client.py @@ -4,7 +4,6 @@ import socket import os -import sys import time import argparse @@ -18,6 +17,7 @@ DEFAULT_PREFIX = 'rte' RUNTIME_SOCKET_NAME = 'telemetry' + class Socket: def __init__(self): @@ -33,9 +33,11 @@ def __del__(self): except: print("Error - Sockets could not be closed") + class Client: - def __init__(self): # Creates a client instance + def __init__(self): + # Creates a client instance self.socket = Socket() self.file_path = None self.run_path = None @@ -45,24 +47,26 @@ def __init__(self): # Creates a client instance def __del__(self): try: if self.unregistered == 0: - self.unregister(); + self.unregister() except: print("Error - Client could not be destroyed") - def getFilepath(self, file_path): # Gets arguments from Command-Line and assigns to instance of client + def getFilepath(self, file_path): + # Gets arguments from Command-Line and assigns to instance of client self.file_path = file_path def setRunpath(self, file_path): self.run_path = os.path.join(get_dpdk_runtime_dir(args.file_prefix), RUNTIME_SOCKET_NAME) - def register(self): # Connects a client to DPDK-instance + def register(self): + # Connects a client to DPDK-instance if os.path.exists(self.file_path): os.unlink(self.file_path) try: self.socket.recv_fd.bind(self.file_path) except socket.error as msg: - print ("Error - Socket binding error: " + str(msg) + "\n") + 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 + "\"}}") @@ -71,30 +75,36 @@ def register(self): # Connects a client to DPDK-instance self.socket.recv_fd.listen(1) self.socket.client_fd = self.socket.recv_fd.accept()[0] - def unregister(self): # Unregister a given client + def unregister(self): + # Unregister a given client self.socket.client_fd.send((API_UNREG + self.file_path + "\"}}").encode()) self.socket.client_fd.close() - def requestMetrics(self): # Requests metrics for given client + def requestMetrics(self): + # Requests metrics for given client self.socket.client_fd.send(METRICS_REQ.encode()) data = self.socket.client_fd.recv(BUFFER_SIZE).decode() print("\nResponse: \n", data) - def repeatedlyRequestMetrics(self, sleep_time): # Recursively requests metrics for given client + def repeatedlyRequestMetrics(self, sleep_time): + # Recursively requests metrics for given client print("\nPlease enter the number of times you'd like to continuously request Metrics:") n_requests = int(input("\n:")) - print("\033[F") #Removes the user input from screen, cleans it up + # Removes the user input from screen, cleans it up + print("\033[F") print("\033[K") for i in range(n_requests): self.requestMetrics() time.sleep(sleep_time) - def requestGlobalMetrics(self): #Requests global metrics for given client + def requestGlobalMetrics(self): + # Requests global metrics for given client self.socket.client_fd.send(GLOBAL_METRICS_REQ.encode()) data = self.socket.client_fd.recv(BUFFER_SIZE).decode() print("\nResponse: \n", data) - def interactiveMenu(self, sleep_time): # Creates Interactive menu within the script + def interactiveMenu(self, sleep_time): + # Creates Interactive menu within the script while self.choice != 4: print("\nOptions Menu") print("[1] Send for Metrics for all ports") @@ -104,7 +114,8 @@ def interactiveMenu(self, sleep_time): # Creates Interactive menu within the scr try: self.choice = int(input("\n:")) - print("\033[F") #Removes the user input for screen, cleans it up + # Removes the user input for screen, cleans it up + print("\033[F") print("\033[K") if self.choice == 1: self.requestMetrics() -- 2.39.0