Пример #1
0
    def _init_devices(self):
        """Reboot all usb devices.

        Note:
            If APC_HOST is not valid, usb devices is not rebooted.
        """
        if self.manual_reset:
            raw_input('Reset golden devices and press enter to continue..')
            return
        elif not settings.APC_HOST:
            return

        tries = 3
        while True:
            try:
                apc = ApcPduController(settings.APC_HOST)
            except EOFError:
                logger.warning('Failed to connect to telnet')
                tries = tries - 1
                if tries:
                    time.sleep(10)
                    continue
                else:
                    logger.error('Fatal error: cannot connect to apc')
                    raise
            else:
                apc.reboot(settings.APC_OUTLET)
                apc.close()
                break

        time.sleep(20)
Пример #2
0
    def _init_devices(self):
        """Reboot all usb devices.

        Note:
            If APC_HOST is not valid, usb devices is not rebooted.
        """
        if self.manual_reset:
            raw_input('Reset golden devices and press enter to continue..')
            return
        elif not settings.APC_HOST:
            if settings.GOLDEN_DEVICE_TYPE != 'OpenThread':
                logger.warning('All golden devices may not be resetted')
                return

            if settings.AUTO_DUT:
                return

            for device in settings.GOLDEN_DEVICES:
                port, _ = device
                try:
                    with OpenThreadController(port) as otc:
                        logger.info('Resetting %s' % port)
                        otc.reset()
                except:
                    logger.exception('Failed to reset device %s' % port)
                    self.history.mark_bad_golden_device(device)

            return

        tries = 3
        while True:
            try:
                apc = ApcPduController(settings.APC_HOST)
            except EOFError:
                logger.warning('Failed to connect to telnet')
                tries = tries - 1
                if tries:
                    time.sleep(10)
                    continue
                else:
                    logger.error('Fatal error: cannot connect to apc')
                    raise
            else:
                apc.reboot(settings.APC_OUTLET)
                apc.close()
                break

        time.sleep(20)