예제 #1
0
 def log_get_systemlog(self, ip, logname):
     ssh = Ssh(ip, self.user, self.password)
     ssh.Exec("journalctl > /home/root/system.log")          
     ssh.Close()
     self.ls.log_print("system", "[getlog] start get log")
     sf = Sftp(ip)
     sf.GetFile("/home/root/system.log","log\\"+logname)            
     # sf.GetFile("/home/root/slamware.stms","log\\slamawre.stms")
     sf.Close()
 def UnSimulator(self):
     try:
         ssh = Ssh(self.ip, self.ssh_user, self.ssh_pass)
         ssh.Connect()
         ssh.Exec(
             "mv /etc/sdp_ref_rplidar.json /home/root/sdp_ref_simulator.json "
         )
         ssh.Exec("mv /home/root/sdp_ref.json /etc/sdp_ref_rplidar.json ")
         ssh.Exec("reboot -n")
         ssh.Close()
         self.ls.log_print("system", "[Simulator Mode] switch successful")
     except:
         self.ls.log_print("system", '[UnSimulator] wrong')
 def GetUnlock(self):
     try:
         ssh = Ssh(self.unlock_info['ip'], self.unlock_info['user'],
                   self.unlock_info['pass'])
         ssh.Connect()
         self.snunlock = ssh.Exec("cd unlock && ./gen_challenge_token.sh " +
                                  self.sn)[2]
         ssh.Close()
         self.ls.log_print("system", "[sn-unlock-num] " + self.snunlock)
         self.data_debug = {'cha-token': self.snunlock}
     except Exception, e:
         self.ls.log_print("system", '[sn-unlock] wrong with get sn unlock')
         raise e
    def TestRealSense(self):
        try:
            ssh = Ssh(self.ip, self.ssh_user, self.ssh_pass)
            ssh.Connect()
            ssh.Exec(
                "echo /usr/bin/slamware_console  depthcam -c tcp status > testrealsense.sh"
            )
            ssh.Exec("chmod a+x testrealsense.sh")
            ssh.Exec("./testrealsense.sh | grep Successfully > realsense.log")
            ssh.Close()

            sf = Sftp(self.ip)
            sf.Connect()
            sf.GetFile("/home/root/realsense.log", ".\\realsense.log")
            sf.Close()
            self.ls.log_print("system", "[Test Realsense] - successful ")
        except:
            self.ls.log_print("system", "[Test Realsense] - fail to ")
    def GetLog(self, logname):
        try:
            ssh = Ssh(self.ip, self.ssh_user, self.ssh_pass)
            '''
            while True:
                try:
                    ssh.Connect()
                    ssh.Exec_noretrun("reboot")
                    print "[getlog] waitting for rebooting to get the log file"

                    break
                except:
                    print "[getlog] wrong with reboot"
                    time.sleep(3)
                    continue
            while True:
                try:
                    ssh.Connect()
                    ssh.Close()
                    print "[getlog] waitting for rebooting to get the log file"
                    break
                except:
                    print "[getlog] waitting for rebooting to get the log file"
                    time.sleep(3)
                    continue
            '''

            ssh.Connect()
            ssh.Exec("journalctl > /home/root/system.log")
            ssh.Close()
            self.ls.log_print("system", "[getlog] start get log")
            sf = Sftp(self.ip)
            sf.Connect()
            sf.GetFile("/home/root/system.log", "log\\" + logname)
            # sf.GetFile("/home/root/slamware.stms","log\\slamawre.stms")
            sf.Close()
            self.ls.log_print("system", "[getlog] switch successful")
        except:
            self.ls.log_print("system", '[UnSimulator] wrong')