00001
00002
00003 import sys, tempfile, zipfile, socket, time, subprocess
00004 from db_check import *
00005 from qnx_cpu_check import *
00006 from qnx_hdd_check import *
00007 from qnx_eth_check import *
00008
00009 from hrpiob_check import *
00010 from md5sum_check import *
00011
00012
00013 class Logger(object):
00014 def __init__(self, filename="Default.log"):
00015 self.terminal = sys.stdout
00016 self.log = open(filename, "a")
00017
00018 def write(self, message):
00019 self.terminal.write(message)
00020 self.log.write(message)
00021 self.terminal.flush()
00022 self.log.flush()
00023
00024 hostname = socket.gethostname()
00025 localtime = time.strftime("%Y%m%d-%H%M%S", time.gmtime())
00026 tmp_base_dir = tempfile.mkdtemp()
00027 tmp_dir = tmp_base_dir+'/%s-%s'%(hostname, localtime)
00028 os.mkdir(tmp_dir)
00029 sys.stdout = Logger('%s/robot-system-check-result.log'%(tmp_dir))
00030
00031 try:
00032 ret = True
00033
00034
00035 print "* Check Environment Variables"
00036 print " Check $PATH ... ", os.environ.get('PATH')
00037 print " Check $LD_LIBRARY_PATH ... ", os.environ.get('LD_LIBRARY_PATH')
00038 print " Check $PYTHON_PATH ... ", os.environ.get('PYTHON_PATH')
00039
00040
00041 ret = db_check("start testing on " + hostname) and ret
00042
00043
00044 print "* Check CPU Info"
00045 ret = qnx_cpu_check() and ret
00046
00047
00048 print "* Check HDD Info"
00049 ret = qnx_hdd_check() and ret
00050
00051
00052
00053
00054
00055
00056 print "* Check Eth Info"
00057 ret = qnx_eth_check() and ret
00058
00059
00060 print "* Check libhrpIo.so"
00061 ret = hrpiob_iob() and ret
00062
00063 ret = md5sum_check_dir(['/usr/pkg/etc', 0xbeef94e03b158101a77526be67d3b9ecL], output_dir = tmp_dir) and ret
00064
00065 print "* Check /usr/local directories"
00066 ret = md5sum_check_dir(['/usr/local', 0x1848d9debc509a0f04620f499d14ceb2L], output_dir = tmp_dir) and ret
00067
00068 print "* Check /usr/pkg directories"
00069 ret = md5sum_check_dir(['/usr/pkg', 0x91f33b46b798da7d176e55367144903L], output_dir = tmp_dir) and ret
00070 ret = md5sum_check_dir(['/usr/pkg/bin', 0x3d8eff565b05b7532b3107b20589cbe6L], output_dir = tmp_dir) and ret
00071 ret = md5sum_check_dir(['/usr/pkg/etc', 0xbeef94e03b158101a77526be67d3b9ecL], output_dir = tmp_dir) and ret
00072 ret = md5sum_check_dir(['/usr/pkg/include',0xe23c6c662a7acf846d4dd25b63fbe6f4L], output_dir = tmp_dir) and ret
00073 ret = md5sum_check_dir(['/usr/pkg/info', 0x3e0519bf78f3258cc72f3d095e942ed8L], output_dir = tmp_dir) and ret
00074 ret = md5sum_check_dir(['/usr/pkg/lib', 0x36d574207bdbb13bc5b898c9870735a6L], output_dir = tmp_dir) and ret
00075 ret = md5sum_check_dir(['/usr/pkg/man', 0xb97c0f124a4170abd7c170fc882b7425L], output_dir = tmp_dir) and ret
00076 ret = md5sum_check_dir(['/usr/pkg/sbin', 0x58a3b20eafea4170215f820182f68483L], output_dir = tmp_dir) and ret
00077 ret = md5sum_check_dir(['/usr/pkg/share', 0x814de4e7c790d11dc4764139b5fb3625L], output_dir = tmp_dir) and ret
00078
00079 print "* Check /opt/nextage-open directories"
00080 ret = md5sum_check_dir(['/opt/nextage-open', 0x5c63a325454cc0dc9c1614c427705a0L], output_dir = tmp_dir) and ret
00081
00082 print "* Check /var files"
00083 import md5sum_var
00084 ret = md5sum_check_files('/var/db', md5sum_var.info) and ret
00085
00086 print "* Check /usr/local files"
00087 import md5sum_usr_local
00088 ret = md5sum_check_files('/usr/local', md5sum_usr_local.info) and ret
00089
00090 print "* Check /usr/pkg files"
00091 import md5sum_usr_pkg_bin
00092 import md5sum_usr_pkg_etc
00093 import md5sum_usr_pkg_include
00094 import md5sum_usr_pkg_info
00095 import md5sum_usr_pkg_lib
00096 import md5sum_usr_pkg_man
00097 import md5sum_usr_pkg_sbin
00098 import md5sum_usr_pkg_share
00099
00100 ret = md5sum_check_files('/usr/pkg/bin', md5sum_usr_pkg_bin.info) and ret
00101 ret = md5sum_check_files('/usr/pkg/etc', md5sum_usr_pkg_etc.info) and ret
00102 ret = md5sum_check_files('/usr/pkg/include', md5sum_usr_pkg_include.info) and ret
00103 ret = md5sum_check_files('/usr/pkg/info', md5sum_usr_pkg_info.info) and ret
00104 ret = md5sum_check_files('/usr/pkg/lib', md5sum_usr_pkg_lib.info) and ret
00105 ret = md5sum_check_files('/usr/pkg/man', md5sum_usr_pkg_man.info) and ret
00106 ret = md5sum_check_files('/usr/pkg/sbin', md5sum_usr_pkg_sbin.info) and ret
00107 ret = md5sum_check_files('/usr/pkg/share', md5sum_usr_pkg_share.info) and ret
00108
00109 print "* Check /opt files"
00110 import md5sum_opt_nextage_open
00111 ret = md5sum_check_files('/opt/nextage-open', md5sum_opt_nextage_open.info) and ret
00112
00113 print "* Check /opt/jsk"
00114 import md5sum_opt_jsk
00115 try:
00116 open("/opt/jsk/.checking", "w+").write("checking by TORK")
00117 except Exception, e:
00118 print e
00119 raise(e)
00120 ret = md5sum_check_files('/opt/jsk', md5sum_opt_jsk.info) and ret
00121
00122 print ""
00123 print "---"
00124 print ""
00125 print " *******"
00126 print "Done all test, Result is ... ", ret
00127 print " *******"
00128
00129 if ret:
00130 print ""
00131 print "--- !!! CONGRATULATIONS !!! --- "
00132 print ""
00133
00134
00135
00136 print('\tInstallability Checker version = 1.0.21')
00137 print('\tFor any issue please report to TORK or https://github.com/start-jsk/rtmros_hironx/issues')
00138
00139 except Exception, e:
00140 ret = False
00141 print "*** "
00142 print "*** Somegthing was wrong...", e.message
00143 print "*** "
00144 finally:
00145 passwd = 'tork0808'
00146 logfilename = 'robot-system-check-result-%s-%s.zip'%(hostname, localtime)
00147 print ""
00148 print "---"
00149 print ""
00150 print "Saving results.... to %s}"%logfilename
00151
00152 try:
00153
00154 db_check(open('%s/robot-system-check-result.log'%(tmp_dir)).read())
00155 subprocess.check_call("cd %s; zip --password %s %s/%s -r ."%(tmp_base_dir, passwd, os.getcwd(), logfilename), shell=True, stdout=subprocess.PIPE)
00156 except Exception, e:
00157 print "*** Somegthing was wrong...", e.message
00158 shutil.rmtree(tmp_base_dir)
00159
00160
00161
00162
00163
00164
00165
00166
00167 shutil.rmtree(tmp_base_dir)
00168
00169 print "Send following file to maintainers"
00170 print " %s"%logfilename
00171 print ""
00172
00173
00174 if ret:
00175 sys.exit(0)
00176 else:
00177 sys.exit(-1)
00178
00179
00180
00181
00182
00183
00184