#!/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()