-
Notifications
You must be signed in to change notification settings - Fork 151
check if connection is actually established #17
check if connection is actually established #17
Conversation
@@ -37,3 +37,7 @@ def print_table(matrix, sep=' ', file=sys.stdout, *args, **kwargs): | |||
|
|||
for row in matrix: | |||
print(format.format(*row).strip(), file=file, *args, **kwargs) | |||
|
|||
|
|||
class ConnectionFail(Exception): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'd rather this live in a different module (maybe wifi.exceptions). I tend to think of utils.py as a file to put stuff that are not related to wifi at all. This ConnectionFail (maybe it could be ConnectionError) is much more related to wifi as a concept that the other functions in this file. Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we have two exceptions already - yes, adding separate module makes sense.
- exception renamed
@@ -35,6 +36,8 @@ def configuration(cell, passkey=None): | |||
raise NotImplementedError | |||
|
|||
|
|||
address_bound_re = re.compile(r'bound to (\d+.\d+.\d+.\d+)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hypothetically I would like to support IPv6... I have no idea what the output would look like, but it might not be all integer values.
I think I better regex would be: r'^bound to (\S+)'
or something like that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, not sure if \S will match an IPv6 address, as it's usually delimited with colons. Also I have no idea and/or proofs that output for v6 will be same in all other parts outside of the address itself, so not sure if it's worth adjusting it here now.
Yet I can add parsing for generic colon delimited IPv6 address.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
\S matches everything that isn't whitespace.
>>> import re
>>> foo = re.compile(r'^foo (\S+)$')
>>> foo.match('foo 1.2.3.4').group(1)
'1.2.3.4'
>>> foo.match('foo 2001:0000::/29').group(1)
'2001:0000::/29'
>>> foo.match('foo ::/128').group(1)
'::/128'
Sorry for falling off the map for a while, I had finals... but now I'm finished with them, I can address these this week. We'll get these done and released, sound good? |
Sure. What still needs addressing here at your opinion? |
Hey @alexykot, I made some comments regarding the regex. Once those are addressed, this is good to merge. Before this gets into master, it needs tests, but I can add those if you want. I was thinking about splitting out a function that parses the output of ifup to do that. |
whoops! sorry. |
I added some tests and the Connection object and merged!!!!! |
This checks if connection is actually established and returns assigned IP address if is, or throws
ConnectionFail
if not.@rockymeza - yes, please add failing tests as you've proposed and I'll try to figure out how to make it not failing.