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
import subprocess
import time
import re
import platform
def testoutput(TestName, Result):
if Result == 0:
print "***" + TestName + ": pass***"
else:
print "***" + TestName + ": fail***"
def checkforerror(process):
ErrorLevel = 0
stdout = ""
try:
stdout = subprocess.check_output(process, shell=True, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError, e:
ErrorLevel = -1
stdout = e.output
print process + "\n" + stdout
return ErrorLevel
def get_stdout(command):
stdout = ""
try:
stdout = subprocess.check_output(command, shell=True, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError, e:
stdout=e.output
print command + "\n" + stdout
return stdout
def checkgator():
(dist, version, id) = platform.linux_distribution()
if id == 'natty' or id == 'oneiric':
checkforerror('apt-get install --assume-yes python-software-properties')
checkforerror('apt-add-repository ppa:linaro-maintainers/arm-ds5 --yes')
checkforerror('apt-get update')
install_gator = checkforerror('apt-get install --assume-yes gator')
testoutput("InstallGator",install_gator)
if install_gator == 0:
time.sleep(5)
else:
sys.exit(1)
lsmod_output = get_stdout('lsmod | grep gator')
modout = re.search("gator", lsmod_output)
if modout > 0:
modout = 0
testoutput("ModuleInserted", modout)
gatord_running = get_stdout('pgrep gatord')
if gatord_running == '':
gatord_running = -1
else:
gatord_running = 0
testoutput("DaemonRunning",gatord_running)
checkgator()
|