Esempio n. 1
0
    def CopyUdasLogs(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: CopyUdasLogs
        # Input: Takes no argument
        # Description: Copy UDAS waveform from Default location to Logs location
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        logger.info("UDAS Directory : " + self.udasDir)

        logger.info("Copying UDAS waveform from Default location to Logs location")

        try :
            os.makedirs(self.udasDir)
        except OSError :
            if not os.path.exists(self.udasDir) :
                return StatusResult.Error("Error in creating UDAS Directory on Automation PC : " + self.udasDir)

        try:
            files = os.listdir(self.logsPath)
            for file in files:
                shutil.copy(os.path.join(self.logsPath, file), os.path.join(self.udasDir, file))
        except Exception as e:
            return StatusResult.Error('Failed to copy UDAS waveform : ', str(e))

        logger.info("Copying UDAS waveform Completed")

        return StatusResult.Success()
Esempio n. 2
0
    def KratosErrorHandler(self):
        """
        -------------------------------------------------------------------------
        # Name: KratosErrorHandler
        # Input: Takes no argument
        # Description: Ping and restart Kratos Application for Recovery
        # Return: StatusResult.Error
        -------------------------------------------------------------------------
        """
        self.retryOnErrorCount = self.retryOnErrorCount + 1
        if self.retryOnErrorCount > 3 :
             return StatusResult.Error("Failled to Handle Error and Restart Kratos after Max Tries.")

        try:
            logger.info("Entered Kratos Error Handling")
            kratosRecovery  = KratosRecovery()
            result = kratosRecovery.PingKratos(TestSuiteConfig.KratosIpAddress, 3600)
            if result.HasError() :
                logger.error("Could Not Ping Kratos Machine in 60 Minutes.")
                return result
            result = kratosRecovery.RestartKratos(TestSuiteConfig.KratosIpAddress)
            logger.info("Rebooting Kratos Software and Test Device")
            if result.HasError():
                return result
            logger.info("Re-Configuring Kratos")
            result = self.KratosSetup()
            if result.HasError():
                return result

            # SetConfigurationFile function is used to recall the cfg file saved by user on Kratos
            configFile = TestCaseConfig.ChannelConfiguration if TestCaseConfig.ChannelConfiguration else TestSuiteConfig.ChannelConfiguration
            result = self.SetConfigurationFile(configFile)
            if result.HasError():
                raise Exception(result.ErrorMessage())

            # SetPowerConfiguration function is used to configure the Voltage, Current & OVP values on KRATOS
            result = self.SetPowerConfiguration()
            if result.HasError():
                raise Exception(result.ErrorMessage())

            # SetAcquisitionConfiguration function is used to set Acquisition parameters on KRATOS.
            result = self.SetAcquisitionConfiguration()
            if result.HasError():
                raise Exception(result.ErrorMessage())

            result = self.SetDefaultOptions()
            if result.HasError():
                raise Exception(result.ErrorMessage())

            logger.info("Booting up Device")
            result = self.PowerOn()
            if result.HasError():
                return result
            result = self.UsbOn()
            if result.HasError():
                return result
        except Exception as e:
            logger.error(str(e))
        return StatusResult.Error("Failing This Attempt To Retry Test After Kratos Restart")
Esempio n. 3
0
    def KratosSetup(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: KratosSetup
        # Input: Takes no argument
        # Description: Sets up KRATOS calibration
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        result = self.SetKratosInIdleState()
        if result.HasError() :
            logger.error("Error in Setting Kratos to IDLE State. " + result.ErrorMessage())
            return StatusResult.Error("Error in Setting Kratos to IDLE State. " + result.ErrorMessage())

        #Checking calibration on KRATOS
        calStatusList = []
        result = self.GetCalibrationStatus(calStatusList)
        if result.HasError():
            return result

        if 'False' in calStatusList[0]:

            logger.warning("Starting self calibration")

            result = self.UsbOff()
            if result.HasError():
                return result

            result = self.PowerOff()
            if result.HasError():
                return result

            result = self.kratosHandler.SelfCalibration()
            if result.HasError():
                return result

            result = self.WaitForIdle()
            if result.HasError():
                return result

            calStatusList = []
            result = self.GetCalibrationStatus(calStatusList)
            if result.HasError():
                return result

            if 'False' in calStatusList[0]:
                return StatusResult.Error('Failed to complete KRATOS self calibration')
            '''
            result = self.PowerOn()
            if result.HasError():
                return result
            '''
        return StatusResult.Success()
Esempio n. 4
0
    def WaitForIdle(self) :
        """
        #-------------------------------------------------------------------------------------------------------------------
		# Name: WaitForIdle
		# Input: Takes No Arguments
		# Description: Waits 5 minutes for Kratos to go to IDLE state
		# Return: StatusResult() object
		#-------------------------------------------------------------------------------------------------------------------
		"""
        count = 0
        while(count < 30):

            busyStatus = self.kratosHandler.IsKratosBusy()
            if busyStatus is None:
                return StatusResult.Error('Failed to read Kratos status')
            if not busyStatus:
                return StatusResult.Success()
            time.sleep(10)
            count = count + 1

        logger.Error("KRATOS failed to return to IDLE state in 5 minutes")
        return StatusResult.Error("KRATOS failed to return to IDLE state in 5 minutes")
Esempio n. 5
0
    def GetKratosIP(self, name):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: GetKratosIP
        # Input: Takes one argument
        #    name : KRATOS host name
        # Description: Gets KRATOS IP address from KRATOS host name
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        if (name is "") or ('kratos' not in name.lower()):
            return StatusResult.Error('KRATOS error: ', ' Incorrect KRATOS name')

        try:
            ipAddress = socket.gethostbyname(name)
        except Exception as e:
            logger.error('KRATOS : Failed to get KRATOS IP address')
            return StatusResult.Error(str(e))

        TestSuiteConfig.KratosIpAddress = str(ipAddress)
        logger.info('KRATOS : ' + 'Name - ' + name + ', IP address - ' + TestSuiteConfig.KratosIpAddress)

        return StatusResult.Success()
Esempio n. 6
0
    def SetKratosInIdleState(self) :
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: KratosSetup
        # Input: Takes no argument
        # Description: Checks Kratos Acquisition State. Set Kratos State to Idle, if Kratos Acquisition state is not in idle.
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """
        if KratosConstants.ExtAcquisitionStatus['IDLE'] != self.kratosHandler.GetExtAcquisitionStatus():
            logger.warning("Already in Acquisition state")
            result = self.StopMeasurement()
            if result.HasError():
                return StatusResult.Error("Failed to stop Acquisition")

        return StatusResult.Success()
Esempio n. 7
0
    def RemoveWaveforms(self):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: RemoveWaveforms
        # Input: Takes no argument
        # Description: Removes the UDAS waveform logs location within the Kratos PC
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        logger.info("Removing waveform Directory : " + self.logsPath + " from Kratos PC")

        try:
            files = os.listdir(self.logsPath)
            for file in files:
                os.remove(os.path.join(self.logsPath, file))
        except Exception as e:
            return StatusResult.Error('Failed to remove waveform directory from Kratos PC', str(e))

        logger.info("Removing waveform directory from Kratos PC Completed")
        return StatusResult.Success()
Esempio n. 8
0
    def SetConfigurationFile(self, configFile):
        """
        #-------------------------------------------------------------------------------------------------------------------
        # Name: SetConfigurationFile
        # Input: Takes one argument
        #       configFile: UDAS configuration file path for KRATOS
        # Description: Sets up channel configuration for KRATOS
        # Return: StatusResult() object
        #-------------------------------------------------------------------------------------------------------------------
        """

        logger.info("Loading KRATOS Channel Configuration : " + configFile)

        if not configFile.endswith('.udas'):
            return StatusResult.Error('KRATOS : ', 'Incorrect Configuration file for KRATOS, UDAS file needed')

        result =self.kratosHandler.LoadChannelConfiguration("C:\\rcm\\cfg\\"+ configFile)
        if result.HasError():
            logger.error("Error in Loading Channel Configuration :  " + result.ErrorMessage())
            recoveryResult = self.KratosErrorHandler()
            return recoveryResult

        return StatusResult.Success()
Esempio n. 9
0
    def InitEnvironmnet(self):
        if 'KratosLite' in TestSuiteConfig.HardwareType:
            try:
                #self.PowerHandler = KratosLite()
                self.PowerHandler = PTTKratoslite()

                result = self.PowerHandler.SetConfigurationFile(
                    TestSuiteConfig.ChannelConfiguration)
                #                 if result.HasError():
                #                     return result
                result = self.PowerHandler.PowerOn()
                result = self.PowerHandler.UsbOn()
                result = Adb.IsDeviceDetected()
                if result.HasError():
                    logger.info("set usb on again")
                    QcUsbSwitch.SetUsbConnection('usb_on')
                    result = Adb.IsDeviceDetected()
                    logger.info("second time: " + str(result.IsSuccess()))
                else:
                    logger.info("first time: " + str(result.IsSuccess()))
                result = Adb.SetAdbRoot()
                if result.HasError():
                    return result
                result = Adb.SetAdbRemount()
                if result.HasError():
                    return result

            except Exception as e:
                return StatusResult.Error('Failed to initialize KRATOSLITE: ',
                                          str(e))
        elif 'Kratos' in TestSuiteConfig.HardwareType:
            logger.info("----------supply with Kratos--------------")
            try:
                #self.PowerHandler = Kratos()
                self.PowerHandler = PTTKratos()
                result = self.PowerHandler.SetConfigurationFile(
                    TestSuiteConfig.ChannelConfiguration)
                #                 if result.HasError():
                #                     return result
                result = self.PowerHandler.PowerOn()
                result = self.PowerHandler.UsbOn()
            except Exception as e:
                logger.info(str(e))
                return StatusResult.Error('Failed to initialize KRATOS: ',
                                          str(e))
        elif 'Monitor' in TestSuiteConfig.HardwareType:
            try:
                self.PowerHandler = PTTPowerMonitor()
            except Exception as e:
                logger.info(str(e))
                return StatusResult.Error(
                    'Failed to initialize PowerMonitor: ', str(e))
        else:
            logger.error(
                "Can't support hardware type, please check TestSuiteConfig.HardwareType"
            )
            return
        logger.info(TestSuiteConfig.HardwareType +
                    " : initialization successful.")
        logger.info("Waiting for device ...")
        result = Adb.WaitForDevice(30)
        logger.info("wait for device ready...")
        result = AdbSettings.ReMountDevice()
        if result.HasError():
            logger.error("Unable to set root & remount privileges")
        self.Wakelock()
        self.Discharging()
        logger.info("Disable charging & Enable wakelock")