From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.toke.dk X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-101.9 required=5.0 tests=BAYES_00,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.2 Received: from mail.toke.dk by mail.toke.dk with LMTP id J9HcEn5Bw12IKgcAOr1fkg (envelope-from ) for ; Wed, 06 Nov 2019 22:56:14 +0100 Authentication-Results: mail.toke.dk; none (SPF check N/A for local connections - client-ip=77.235.54.103; helo=web6.sd.eurovps.com; envelope-from=flent-users-bounces@flent.org; receiver=) Authentication-Results: mail.toke.dk; dkim=fail reason="signature verification failed" (1024-bit key) header.d=github.com header.i=@github.com header.b=bx9K+9Lc Received: from web6.sd.eurovps.com (web6.sd.eurovps.com [77.235.54.103]) by mail.toke.dk (Postfix) with ESMTPS id 2734D6A0089 for ; Wed, 6 Nov 2019 22:56:12 +0100 (CET) Received: from [::1] (port=37714 helo=web6.sd.eurovps.com) by web6.sd.eurovps.com with esmtp (Exim 4.92) (envelope-from ) id 1iSTHe-00CliP-OW; Wed, 06 Nov 2019 23:56:10 +0200 Received: from out-20.smtp.github.com ([192.30.252.203]:37737) by web6.sd.eurovps.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1iSTHT-00CldG-1b for flent-users@flent.org; Wed, 06 Nov 2019 23:56:05 +0200 Date: Wed, 06 Nov 2019 13:55:18 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=github.com; s=pf2014; t=1573077318; bh=Fpu+hOLpsGSNni3TdlkEJCnl7i7UTO6VD7FyfRSUo2M=; h=Date:From:Reply-To:To:Cc:In-Reply-To:References:Subject:List-ID: List-Archive:List-Post:List-Unsubscribe:From; b=bx9K+9LcKFNwsjdCE424YBnJtI8pJqDUzfJXXjpg4ZZdgBWtSghNIvvZbxES+OZyE MgZZoXifRb482TZ+OH3WnNX/gVXBUlC383FisCjnimay+GtQqugcoxYzIBz/GqHJYH 9f8O8qiQncOFSfOsh8Kle0XaHnhU7XD6aiei8NAU= From: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= To: tohojo/flent Message-ID: In-Reply-To: References: Mime-Version: 1.0 Precedence: list X-GitHub-Sender: tohojo X-GitHub-Recipient: flent-users X-GitHub-Reason: subscribed X-Auto-Response-Suppress: All X-GitHub-Recipient-Address: flent-users@flent.org Subject: Re: [Flent-users] [tohojo/flent] added wifi data function (#188) X-BeenThere: flent-users@flent.org X-Mailman-Version: 2.1.27 List-Id: Flent discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: tohojo/flent Cc: Subscribed Content-Type: multipart/mixed; boundary="===============2444979256928267743==" Errors-To: flent-users-bounces@flent.org Sender: "Flent-users" X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - web6.sd.eurovps.com X-AntiAbuse: Original Domain - toke.dk X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - flent.org X-Get-Message-Sender-Via: web6.sd.eurovps.com: acl_c_authenticated_local_user: mailman/mailman X-Authenticated-Sender: web6.sd.eurovps.com: mailman@flent.org --===============2444979256928267743== Content-Type: multipart/alternative; boundary="--==_mimepart_5dc3414656c5c_3ddf3fccc04cd96c99959"; charset=UTF-8 Content-Transfer-Encoding: 7bit ----==_mimepart_5dc3414656c5c_3ddf3fccc04cd96c99959 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit tohojo requested changes on this pull request. This is a good start! There are some details to fix below. Also, you'll need to add a proper commit message. The first line should be a oneline description of the change, prefixed by the system you are touching (so something like "metadata: Add parsing of WiFi status information". Then add a description of what your change does (a shortish paragraph is probably enough for this change), with an example of the output you are parsing embedded in the commit message. You'll also need to add a Signed-off-by tag, as the bot says. When revising, you can rewrite the commit in your local git tree, and force-push it to the same branch; that will update this pull request directly, while still keeping the history clean. Feel free to ask clarifying questions, of course :) > @@ -514,3 +514,27 @@ def get_module_versions(): module_versions[m] = v return module_versions + +def get_wifi_data(iface): You'll also need to add appropriate calls to this function in record_metadata(); I'd suggest putting them along with the calls to get_ip_addrs() and get_gateways() > @@ -514,3 +514,27 @@ def get_module_versions(): module_versions[m] = v return module_versions + +def get_wifi_data(iface): + wifi_data = {} + unwanted_keys = ["Interface", "ifindex", "wdev", "wiphy"] + output = get_command_output("iw dev %s info" % iface) + if output is not None: + for line in output.splitlines(): + parts = line.split() This needs to discard empty lines first > @@ -514,3 +514,27 @@ def get_module_versions(): module_versions[m] = v return module_versions + +def get_wifi_data(iface): + wifi_data = {} + unwanted_keys = ["Interface", "ifindex", "wdev", "wiphy"] + output = get_command_output("iw dev %s info" % iface) + if output is not None: + for line in output.splitlines(): + parts = line.split() + + if parts[0] in unwanted_keys: + continue + k,v = parts[0], parts[1] Since you're doing the split here, better to use the 'k' and 'v' variables further down instead of parts[0] and parts[1] > @@ -514,3 +514,27 @@ def get_module_versions(): module_versions[m] = v return module_versions + +def get_wifi_data(iface): + wifi_data = {} + unwanted_keys = ["Interface", "ifindex", "wdev", "wiphy"] + output = get_command_output("iw dev %s info" % iface) + if output is not None: + for line in output.splitlines(): + parts = line.split() + + if parts[0] in unwanted_keys: + continue + k,v = parts[0], parts[1] + if parts[0] == 'txpower': + v = float(parts[1]) + if parts[0] == 'channel': Please add a comment with an example of the line you are trying to parse with this > + + if parts[0] in unwanted_keys: + continue + k,v = parts[0], parts[1] + if parts[0] == 'txpower': + v = float(parts[1]) + if parts[0] == 'channel': + v = {} + v['number'] =int(parts[1]) + v['band'] = int(parts[2].strip("(")); + v['width'] = int(parts[5]) + v['center1'] = int(parts[8]) + + wifi_data[k] = v + + return wifi_data Missing newline at the end of the file > @@ -514,3 +514,27 @@ def get_module_versions(): module_versions[m] = v return module_versions + +def get_wifi_data(iface): + wifi_data = {} + unwanted_keys = ["Interface", "ifindex", "wdev", "wiphy"] + output = get_command_output("iw dev %s info" % iface) + if output is not None: + for line in output.splitlines(): + parts = line.split() Also, you'll need to handle unwanted lines. On my system, the output looks like this: ``` Interface wlan0 ifindex 3 wdev 0x1 addr 98:de:ad:ca:fe:85 ssid myssid type managed wiphy 0 channel 36 (5180 MHz), width: 80 MHz, center1: 5210 MHz txpower 22.00 dBm multicast TXQ: qsz-byt qsz-pkt flows drops marks overlmt hashcol tx-bytes tx-packets 0 0 0 0 0 0 0 0 0 ``` Your parser will choke on the bit at the bottom; I think it's probably fine if you just abort parsing when you get to the "multicast TXQ" line... -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/tohojo/flent/pull/188#pullrequestreview-312762596 ----==_mimepart_5dc3414656c5c_3ddf3fccc04cd96c99959 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit

@tohojo requested changes on this pull request.

This is a good start! There are some details to fix below. Also, you'll need to add a proper commit message. The first line should be a oneline description of the change, prefixed by the system you are touching (so something like "metadata: Add parsing of WiFi status information". Then add a description of what your change does (a shortish paragraph is probably enough for this change), with an example of the output you are parsing embedded in the commit message. You'll also need to add a Signed-off-by tag, as the bot says.

When revising, you can rewrite the commit in your local git tree, and force-push it to the same branch; that will update this pull request directly, while still keeping the history clean.

Feel free to ask clarifying questions, of course :)


In flent/metadata.py:

> @@ -514,3 +514,27 @@ def get_module_versions():
             module_versions[m] = v
 
     return module_versions
+
+def get_wifi_data(iface):

You'll also need to add appropriate calls to this function in record_metadata(); I'd suggest putting them along with the calls to get_ip_addrs() and get_gateways()


In flent/metadata.py:

> @@ -514,3 +514,27 @@ def get_module_versions():
             module_versions[m] = v
 
     return module_versions
+
+def get_wifi_data(iface):
+    wifi_data = {}
+    unwanted_keys = ["Interface", "ifindex", "wdev", "wiphy"]
+    output = get_command_output("iw dev %s info" % iface)
+    if output is not None:
+        for line in output.splitlines():
+            parts = line.split() 

This needs to discard empty lines first


In flent/metadata.py:

> @@ -514,3 +514,27 @@ def get_module_versions():
             module_versions[m] = v
 
     return module_versions
+
+def get_wifi_data(iface):
+    wifi_data = {}
+    unwanted_keys = ["Interface", "ifindex", "wdev", "wiphy"]
+    output = get_command_output("iw dev %s info" % iface)
+    if output is not None:
+        for line in output.splitlines():
+            parts = line.split() 
+
+            if parts[0]  in unwanted_keys:
+                continue
+            k,v = parts[0], parts[1]

Since you're doing the split here, better to use the 'k' and 'v' variables further down instead of parts[0] and parts[1]


In flent/metadata.py:

> @@ -514,3 +514,27 @@ def get_module_versions():
             module_versions[m] = v
 
     return module_versions
+
+def get_wifi_data(iface):
+    wifi_data = {}
+    unwanted_keys = ["Interface", "ifindex", "wdev", "wiphy"]
+    output = get_command_output("iw dev %s info" % iface)
+    if output is not None:
+        for line in output.splitlines():
+            parts = line.split() 
+
+            if parts[0]  in unwanted_keys:
+                continue
+            k,v = parts[0], parts[1]
+            if parts[0] == 'txpower':
+               v = float(parts[1])
+            if parts[0] == 'channel':

Please add a comment with an example of the line you are trying to parse with this


In flent/metadata.py:

> +
+            if parts[0]  in unwanted_keys:
+                continue
+            k,v = parts[0], parts[1]
+            if parts[0] == 'txpower':
+               v = float(parts[1])
+            if parts[0] == 'channel':
+                v = {}
+                v['number'] =int(parts[1])
+                v['band'] = int(parts[2].strip("("));
+                v['width'] = int(parts[5])
+                v['center1'] = int(parts[8])
+                
+            wifi_data[k] = v
+
+    return wifi_data

Missing newline at the end of the file


In flent/metadata.py:

> @@ -514,3 +514,27 @@ def get_module_versions():
             module_versions[m] = v
 
     return module_versions
+
+def get_wifi_data(iface):
+    wifi_data = {}
+    unwanted_keys = ["Interface", "ifindex", "wdev", "wiphy"]
+    output = get_command_output("iw dev %s info" % iface)
+    if output is not None:
+        for line in output.splitlines():
+            parts = line.split() 

Also, you'll need to handle unwanted lines. On my system, the output looks like this:

Interface wlan0
	ifindex 3
	wdev 0x1
	addr 98:de:ad:ca:fe:85
	ssid myssid
	type managed
	wiphy 0
	channel 36 (5180 MHz), width: 80 MHz, center1: 5210 MHz
	txpower 22.00 dBm
	multicast TXQ:
		qsz-byt	qsz-pkt	flows	drops	marks	overlmt	hashcol	tx-bytes	tx-packets
		0	0	0	0	0	0	0	0		0

Your parser will choke on the bit at the bottom; I think it's probably fine if you just abort parsing when you get to the "multicast TXQ" line...


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

----==_mimepart_5dc3414656c5c_3ddf3fccc04cd96c99959-- --===============2444979256928267743== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Flent-users mailing list Flent-users@flent.org http://flent.org/mailman/listinfo/flent-users_flent.org --===============2444979256928267743==--