/usr/share/checkbox/scripts/network_check is in checkbox 0.13.7.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #!/usr/bin/python
"""
Check that it's possible to establish a http connection against
ubuntu.com
"""
from subprocess import call
from optparse import OptionParser, Option
import urllib2
import sys
def check_url(url):
"""
Open URL and return True if no exceptions were raised
"""
try:
urllib2.urlopen(url)
except urllib2.URLError:
return False
return True
def main():
"""
Check HTTP and connection
"""
usage = 'Usage %prog [OPTIONS]'
parser = OptionParser(usage)
parser.add_option('-a', '--auto',
action='store_true',
default=False,
help='Runs in Automated mode, with no visible output')
(options,args) = parser.parse_args()
url = { "http": "http://cdimage.ubuntu.com/daily/current/" }
results = {}
for protocol, value in url.iteritems():
results[protocol] = check_url(value)
bool2str = {True: 'Success', False: 'Failed'}
message = ("HTTP connection: %(http)s\n"
% dict([(protocol, bool2str[value])
for protocol, value in results.iteritems()]))
command = ["zenity", "--title=Network",
"--text=%s" % message]
if all(results.itervalues()):
command.append("--info")
else:
command.append("--error")
if not options.auto:
call(command)
if any(results.itervalues()):
return 0
else:
return 1
if __name__ == "__main__":
sys.exit(main())
|