This repository was archived by the owner on May 11, 2018. It is now read-only.
rpi_network_conn.py updates
#18
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
get_wifi_listwlan_statussince it wasn't being used for anythingreturncodesince it wasn't being used for anything[]ifsudo ifup wlan0fails. It would seem if the wifi is down, the next call to check nearby wifi access points will likely fail as well.[]ifsudo iwlist wlan0 scanfails. It doesn't seem to make sense to try to iterate an empty list, create a set out of an empty list and then try to sort an empty set.rangeloop replaced withenumeratesince both the index and value are needediw_list[x].strip()was being created 5 times. Also, each instance was then creating another slice. To cut down on unnecessary copies, thecurrentvariable saves the stripped current line.str.startswithdoesn't create unnecessary copies eitherendvariable was created to reuse the same slice 4 timeslist(...)inside ofsorted(...)since it was creating an unnecessary list instead of just creating the sorted list directly fromset(wifi_list)add_wifissidonce instead of creating it via concatenation on each iteration of the loopwifi_key_infoonce instead of (potentially) multiple times inside the loop (also,if wifi_exists is False)xrangeinstead ofrangetextwrap.dedentto keep proper indentationfile.writelinesinstead offile.writefor each separate lineinternet_statusresponsesince it wasn't being used for anythingreturn Falseimmediately ifurllib2.URLErroris raisedreturn Trueto theelsestatement (for readability and to stay consistent with other project files)reset_wifitextwrap.dedentto createlinesvpn_statussince it wasn't being used for anythingreturncodesince it wasn't being used for anythingreturn Falseimmediately ifCalledProcessErroris raisedreturn Truein theelsesinceCalledProcessErroris only raised for a non-zero exit code (no need to checkreturncode == 0)