First, the script was renamed to gateway_ping_test because internet_test
was misleading. However, the potentially offending code is still there.

The ping() method parses ping's output according to a regex, and then
refers to the regex's matches. If ping output didn't match the regex,
the match list will be empty, prompting this error.

>From my analysis this could happen only two ways:
1- Ping is run with a different locale, causing the summary line to be in a 
different language and matching to fail.
2- Ping is simply not present. Unlike the newer subprocess.check_* functions, 
the popen mechanism the script uses will not throw an exception if the command 
fails to run; it will just return an empty list.

A possible failure scenario is if the ping target is not resolvable, but
in this case the test handles it correctly.

Work to do:
Refactor the ping() method so that:
1- Runs ping in an unlocalized environment (LANG=en_US.UTF-8 and LANGUAGE=en, 
or maybe C or POSIX).
2- Preferrably, it uses subprocess.check_output to run ping, and properly 
handles the exception with a fatal error due to absence of ping. "Properly 
handles" may involve actually ignoring the exception to let the invoking code 
decide what to do.
3- If the regex doesn't match ping output at all, assume the internet 
connection is down. This can be done by just returning None if it didn't match, 
the rest of the code will interpret that as "no connection".
4- The code invoking ping() could handle the CalledProcessError when ping is 
absent to print a relevant error message.


** Changed in: checkbox
   Importance: Undecided => Medium

** Changed in: checkbox
       Status: New => Triaged

** Changed in: checkbox (Ubuntu)
       Status: New => Triaged

** Changed in: checkbox
    Milestone: None => 2014-jan-31

** Changed in: checkbox (Ubuntu)
    Milestone: None => ubuntu-14.04-feature-freeze

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1232774

Title:
  internet_test crashed with TypeError in ping(): 'NoneType' object is
  not subscriptable

To manage notifications about this bug go to:
https://bugs.launchpad.net/checkbox/+bug/1232774/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to