예제 #1
0
파일: i2c.py 프로젝트: ed-aicradle/monotone
        # Make sure we can "see" the i2c bus before attempting to test
        # attached components, duh.  (We're only interested in bus 0.)
        result, spewage = execute_command('/usr/bin/i2cdetect 0')
        if not result:
            self.log('ERROR: Cannot access the I2C bus: %s' % spewage)
            self._nerrors += 1
        else:
            self._i2crtc.runtest()
            self._nwarnings += self._i2crtc.nwarnings
            self._nerrors += self._i2crtc.nerrors
        return self.passed()

    def set_hwclock(self, unix_time):
        unix_time = float(unix_time)
        time_tuple = time.localtime(unix_time)
        cmd = 'date -s "%s"' % (time.strftime('%m/%d/%Y %H:%M:%S', time_tuple))
        self.log('RTC: Running command - %s' % cmd)
        result, spewage = execute_command(cmd)
        if not result:
            self.log('ERROR: Could not set RTC time: %s' % spewage)
            return False
        result, spewage = execute_command('hwclock -wu')
        if not result:
            self.log('ERROR: Could not execute hwclock: %s' % spewage)
            return False
        return True


f = Factory()
f.register('I2CTester', (I2CTester, ))