~kelemeng/checkbox/bug868571

« back to all changes in this revision

Viewing changes to scripts/internet_question

  • Committer: Marc Tardif
  • Date: 2007-10-04 23:12:10 UTC
  • Revision ID: marc.tardif@canonical.com-20071004231210-unxckndkgndxfdp6
Refactored questions to use templates and scripts which fixes bug #149195.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
import os
 
4
import re
 
5
 
 
6
 
 
7
TEST_DOMAIN = "canonical.com"
 
8
 
 
9
command = "ping -q -w4 -c2 %s" % TEST_DOMAIN
 
10
reg = re.compile(r"(\d) received")
 
11
ping = os.popen(command)
 
12
num_packets = 0
 
13
while 1:
 
14
    line = ping.readline()
 
15
    if not line: break
 
16
    received = re.findall(reg, line)
 
17
    if received:
 
18
        num_packets = int(received[0])
 
19
 
 
20
if num_packets == 0:
 
21
    status = "No internet connection"
 
22
elif num_packets == 2:
 
23
    status = "Internet connection fully established"
 
24
else:
 
25
    status = "Connection established by problematic"
 
26
 
 
27
print status