From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 83EC8A04E7; Wed, 4 Nov 2020 08:00:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 174ADBE63; Wed, 4 Nov 2020 08:00:56 +0100 (CET) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 084CBBE61 for ; Wed, 4 Nov 2020 08:00:54 +0100 (CET) Received: by mail-pf1-f196.google.com with SMTP id z3so10142268pfz.6 for ; Tue, 03 Nov 2020 23:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=loNEFgORafRS9FueTMnOrSNZ7lKdSgzdKYiA1iyjfKs=; b=Qxq3/Ez/x8yFPO81uBXG0LgpPt1UonuBlcgUjk7DTf3yxcQ76Xa0SFqNqnXIFZK6ZF zoJbpLFvcvoUdvFlLL8PVAOdg3Ur3TS0/iQdkmOvQSmX6n0B1IuaE4Rfak+cLkbX5sia 6vBMmDbvvtElmaU6m9xDIiiFE1hMwgE7YEubctGgwtk3m+mxAciEutWyPSQ94KeTTAky yH6YPFtXnD22yWqkHpekkCnFDjUvcw8ekRw+q4oHFq4V+egJRYyyBhpMocedDqhxiWs9 ng/ZGlI1KU41EDjRspZQRwsAw63cfzaOSpz38tioXitufLwya8S/2f2uqeehEo8ePPPK n8SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=loNEFgORafRS9FueTMnOrSNZ7lKdSgzdKYiA1iyjfKs=; b=IArcziqVR16CDA7XTmBs/ViEO+siMrvO2wVOfvqIPEYnx3fLFD++EMH/0mC13evQbJ tp20YTA/6ouanfuIU3jDxK2dxApWDjBGocxzV1kWebnKDA+z5PfKEqWNNqC/1/g6QIit GZBdujO4X3LpWL5BOjjfLKAdlPIoicnXam4flzPEV/2EX0KDbZnKLssejnaS0aPXgFVO 4O0W8MGDdQYvs91KJHTwvwgl+2Sk2AD4onQVHSFRLRD3n1hbFdORouAhRynngaUC4703 MBt5AVvrb3P4JWh/zTTInfQDS//xv0ycVFi+d574WEm8ZKh9v1H9X5Xi+nRSY8g5NxPY F9Rw== X-Gm-Message-State: AOAM5338Ip4e7ahlikx8wqlchyUR52BV60L/3enJ+IBkXKVmlGbNQgBn oMrOOdfmPjuXHmrQDMGTGoUq3Q== X-Google-Smtp-Source: ABdhPJwvLluyns2p9OgreJMBuj8eGDFHTbwMyVW2kubcEwFsmOJwhTlbbwKg24eKFQa+oqwyRd7Ftg== X-Received: by 2002:aa7:8205:0:b029:18b:3691:e447 with SMTP id k5-20020aa782050000b029018b3691e447mr6073575pfi.69.1604473252241; Tue, 03 Nov 2020 23:00:52 -0800 (PST) Received: from hermes.corp.microsoft.com (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z12sm1262684pfg.123.2020.11.03.23.00.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Nov 2020 23:00:51 -0800 (PST) From: Stephen Hemminger To: kevin.laatz@intel.com Cc: dev@dpdk.org, Stephen Hemminger , Bruce Richardson Date: Tue, 3 Nov 2020 23:00:43 -0800 Message-Id: <20201104070043.27879-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200906013133.26360-11-stephen@networkplumber.org> References: <20200906013133.26360-11-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2] dpdk-telemetry-client: fix some pylint warnings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Convert comments to docstrings as appropriate. Remove unnecessary paren in if statement. Remove extra whitespace after print. Remove extra semicolon; this is not C. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- v2 - fix a few more warnings. split this patch from the bundle usertools/dpdk-telemetry-client.py | 34 ++++++++++++++++++------------ 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/usertools/dpdk-telemetry-client.py b/usertools/dpdk-telemetry-client.py index d8e439027cfc..8da3e9caa126 100755 --- a/usertools/dpdk-telemetry-client.py +++ b/usertools/dpdk-telemetry-client.py @@ -16,7 +16,7 @@ DEFAULT_FP = "/var/run/dpdk/default_client" class Socket: - + ''' Opens AF_UNIX sockets to telemetry server ''' def __init__(self): self.send_fd = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET) self.recv_fd = socket.socket(socket.AF_UNIX, socket.SOCK_SEQPACKET) @@ -31,8 +31,9 @@ def __del__(self): print("Error - Sockets could not be closed") class Client: - - def __init__(self): # Creates a client instance + ''' Calls for communication with telemetry server ''' + def __init__(self): + ''' Creates a client instance ''' self.socket = Socket() self.file_path = None self.choice = None @@ -41,20 +42,22 @@ 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 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("/var/run/dpdk/rte/telemetry") JSON = (API_REG + self.file_path + "\"}}") @@ -63,16 +66,19 @@ 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 @@ -81,12 +87,14 @@ def repeatedlyRequestMetrics(self, sleep_time): # Recursively requests metrics f 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") @@ -116,7 +124,7 @@ def interactiveMenu(self, sleep_time): # Creates Interactive menu within the scr sleep_time = 1 file_path = "" - if (len(sys.argv) == 2): + if len(sys.argv) == 2: file_path = sys.argv[1] else: print("Warning - No filepath passed, using default (" + DEFAULT_FP + ").") -- 2.27.0