Re: [Flent-users] [tohojo/flent] added wifi data function (#188)

2019-11-17 Thread Emilly Albuquerque
@emys-alb pushed 3 commits.

8572d423f9f915ff50eb5bcd8c7561877001df04  added wifi data function
743bde155db9a65892e16a73c816f74132697636  Merge branch 'master' of 
https://github.com/emys-alb/flent
6fb18d88273d34c2e18f44e7ae7778bff0f590d8  Added wifi data function


-- 
You are receiving this because you are subscribed to this thread.
View it on GitHub:
https://github.com/tohojo/flent/pull/188/files/8ace04f71dbe6e8f7ac3a02cd1d0f8ffefa08c48..6fb18d88273d34c2e18f44e7ae7778bff0f590d8
___
Flent-users mailing list
Flent-users@flent.org
http://flent.org/mailman/listinfo/flent-users_flent.org


Re: [Flent-users] [tohojo/flent] added wifi data function (#188)

2019-11-15 Thread Toke Høiland-Jørgensen
tohojo commented on this pull request.



> @@ -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':

No, I meant the 'channel' 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#discussion_r346839149___
Flent-users mailing list
Flent-users@flent.org
http://flent.org/mailman/listinfo/flent-users_flent.org


Re: [Flent-users] [tohojo/flent] added wifi data function (#188)

2019-11-15 Thread Toke Høiland-Jørgensen
tohojo commented on this pull request.



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

You added a new function. But it doesn't do anything until you add some code 
that calls that function and does something with the result. Look at the how 
get_ip_addrs() is being called in record_metadata() for an example...

-- 
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#discussion_r346838936___
Flent-users mailing list
Flent-users@flent.org
http://flent.org/mailman/listinfo/flent-users_flent.org


Re: [Flent-users] [tohojo/flent] added wifi data function (#188)

2019-11-14 Thread Emilly Albuquerque
emys-alb commented on this pull request.



> @@ -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':

like 'txpower: 15.0'?

-- 
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#discussion_r346590781___
Flent-users mailing list
Flent-users@flent.org
http://flent.org/mailman/listinfo/flent-users_flent.org


Re: [Flent-users] [tohojo/flent] added wifi data function (#188)

2019-11-14 Thread Emilly Albuquerque
emys-alb commented on this pull request.



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

I didn't get it

-- 
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#discussion_r346590542___
Flent-users mailing list
Flent-users@flent.org
http://flent.org/mailman/listinfo/flent-users_flent.org


Re: [Flent-users] [tohojo/flent] added wifi data function (#188)

2019-11-06 Thread Toke Høiland-Jørgensen
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-bytestx-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___
Flent-users mailing list
Flent-users@flent.org
http://flent.org/mailman/listinfo/flent-users_flent.org