sleeptenmin.py 774 字节
Newer Older
1 2
#!/usr/bin/python

3
import os
4 5
import time

6
from avocado import main
7
from avocado import Test
8 9


10
class SleepTenMin(Test):
11 12 13 14 15

    """
    Sleeps for 10 minutes
    """

16
    def runTest(self):
17 18 19
        """
        Sleep for length seconds.
        """
20 21 22
        cycles = int(self.params.get('sleep_cycles', default=1))
        length = int(self.params.get('sleep_length', default=600))
        method = self.params.get('sleep_method', default='builtin')
23 24 25

        for cycle in xrange(0, cycles):
            self.log.debug("Sleeping for %.2f seconds", length)
26
            if method == 'builtin':
27
                time.sleep(length)
28
            elif method == 'shell':
29
                os.system("sleep %s" % length)
30
            self.report_state()
31 32

if __name__ == "__main__":
33
    main()