From: "Toke Høiland-Jørgensen" <notifications@github.com> To: tohojo/flent <flent@noreply.github.com> Cc: Subscribed <subscribed@noreply.github.com> Subject: Re: [Flent-users] [tohojo/flent] metadata: Add parsing of WiFi status information (#192) Date: Tue, 26 Nov 2019 02:29:06 -0800 [thread overview] Message-ID: <tohojo/flent/pull/192/review/322868381@github.com> (raw) In-Reply-To: <tohojo/flent/pull/192@github.com> [-- Attachment #1.1: Type: text/plain, Size: 3202 bytes --] tohojo requested changes on this pull request. Looking good! Only a few minor details to fix. Also, please add some text to the commit message explaining the change; only needs to be a line or two for this (put that before the signed-off-by). > + + for line in output.splitlines(): + + if len(line.strip()) >= 1: + parts = line.split() + k,v = parts[0], parts[1] + + if k in unwanted_keys: + continue + + if k == 'txpower': + v = float(parts[1]) + + if k == 'channel': + # This condition will return a dict with all the values of the channel + # Output will be {'addr':..., channel': {'band': 2462, 'center1': 2462, 'number': 11, 'width': 20}, 'ssid':...} The indentation is off on the second comment line. Also, please add an example of the input (i.e., the line you're trying to parse) along with the output. > + if k in unwanted_keys: + continue + + if k == 'txpower': + v = float(parts[1]) + + if k == 'channel': + # This condition will return a dict with all the values of the channel + # Output will be {'addr':..., channel': {'band': 2462, 'center1': 2462, 'number': 11, 'width': 20}, 'ssid':...} + v = {} + v['number'] =int(parts[1]) + v['band'] = int(parts[2].strip("(")); + v['width'] = int(parts[5]) + v['center1'] = int(parts[8]) + + if k == "multicast TXQ": Please add a short comment explaining this (could just be, e.g., "No interesting output after this") > + if k == 'txpower': + v = float(parts[1]) + + if k == 'channel': + # This condition will return a dict with all the values of the channel + # Output will be {'addr':..., channel': {'band': 2462, 'center1': 2462, 'number': 11, 'width': 20}, 'ssid':...} + v = {} + v['number'] =int(parts[1]) + v['band'] = int(parts[2].strip("(")); + v['width'] = int(parts[5]) + v['center1'] = int(parts[8]) + + if k == "multicast TXQ": + break + + wifi_data[k] = v This should be inside the if statement. Alternatively, you could save one level of indentation by reversing the if statement above and turning it into a "continue". I.e., replace ``` if len(line.strip()) >= 1: # lots of code here ``` with ``` if not line.strip(): continue # code here (unindented) ``` Up to you which you prefer :) > @@ -138,6 +138,7 @@ def record_metadata(results, extended, hostnames): if extended: m['IP_ADDRS'] = get_ip_addrs() m['GATEWAYS'] = get_gateways() + m['WIFI_DATA'] =get_wifi_data() Missing space after = -- 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/192#pullrequestreview-322868381 [-- Attachment #1.2: Type: text/html, Size: 5631 bytes --] [-- Attachment #2: Type: text/plain, Size: 151 bytes --] _______________________________________________ Flent-users mailing list Flent-users@flent.org http://flent.org/mailman/listinfo/flent-users_flent.org
next parent reply other threads:[~2019-11-26 10:30 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <tohojo/flent/pull/192@github.com> 2019-11-26 10:29 ` Toke Høiland-Jørgensen [this message] 2019-12-02 12:19 ` Toke Høiland-Jørgensen 2019-12-02 12:29 ` Toke Høiland-Jørgensen 2019-12-02 12:29 ` Toke Høiland-Jørgensen 2019-12-02 12:35 ` Toke Høiland-Jørgensen
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://lists.flent.org/postorius/lists/flent-users.flent.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=tohojo/flent/pull/192/review/322868381@github.com \ --to=notifications@github.com \ --cc=flent@noreply.github.com \ --cc=reply+AHVNJP6WSJONFVETYKW7UFN35IYPFEVBNHHB67XBGE@reply.github.com \ --cc=subscribed@noreply.github.com \ --subject='Re: [Flent-users] [tohojo/flent] metadata: Add parsing of WiFi status information (#192)' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox