internet_test crashed with TypeError in ping(): 'NoneType' object is not subscriptable
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Checkbox Provider - Base |
Fix Released
|
Undecided
|
Unassigned | ||
checkbox (Ubuntu) |
Fix Released
|
Medium
|
Unassigned |
Bug Description
running system testing and crash appeared upon landing on the optical/read_sr0 test after performing the previous tests
ProblemType: Crash
DistroRelease: Ubuntu 13.10
Package: checkbox 0.16.6
ProcVersionSign
Uname: Linux 3.11.0-9-generic x86_64
ApportVersion: 2.12.5-0ubuntu1
Architecture: amd64
Date: Sun Sep 29 10:52:59 2013
EcryptfsInUse: Yes
ExecutablePath: /usr/lib/
InstallationDate: Installed on 2012-11-29 (303 days ago)
InstallationMedia: Ubuntu 12.10 "Quantal Quetzal" - Release amd64 (20121017.5)
InterpreterPath: /usr/bin/python3.3
MarkForUpload: True
ProcCmdline: /usr/bin/python3 /usr/share/
PythonArgs: ['/usr/
SourcePackage: checkbox
Title: internet_test crashed with TypeError in ping(): 'NoneType' object is not subscriptable
UpgradeStatus: Upgraded to saucy on 2013-09-28 (0 days ago)
UserGroups: adm cdrom dip lpadmin plex plugdev sambashare sudo vboxusers
Related branches
- Zygmunt Krynicki (community): Approve
-
Diff: 47 lines (+19/-11)1 file modifiedproviders/plainbox-provider-checkbox/bin/gateway_ping_test (+19/-11)
tags: | removed: need-duplicate-check |
Changed in checkbox (Ubuntu): | |
importance: | Undecided → Medium |
information type: | Private → Public |
tags: | added: scripts |
Changed in checkbox: | |
milestone: | 2014-jan-31 → 2014-feb-14 |
Changed in checkbox: | |
milestone: | 2014-feb-14 → 2013-feb-28 |
Changed in checkbox: | |
milestone: | 2013-feb-28 → 2014-mar-14 |
Changed in checkbox: | |
milestone: | 2014-mar-14 → 2014-apr-11 |
no longer affects: | checkbox |
Changed in plainbox-provider-checkbox: | |
status: | New → Confirmed |
Changed in checkbox (Ubuntu): | |
milestone: | ubuntu-14.04-feature-freeze → ubuntu-16.04 |
status: | Triaged → Fix Released |
Changed in plainbox-provider-checkbox: | |
status: | Confirmed → Fix Released |
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: 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.
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.
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.