aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/autobuilder/buildsteps/Sleep.py
blob: 91dcbed37df258b9759113415cda7713d26baa8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
'''
Created on Dec 22, 2012

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2013, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "pidge@toganlabs.com"
'''


from buildbot.steps.shell import ShellCommand

class Sleep(ShellCommand):
    haltOnFailure = True
    flunkOnFailure = True
    name = "Sleep"
    def __init__(self, factory, argdict=None, **kwargs):
        self.time="0"
        self.funny="False"
        self.factory = factory
        for k, v in argdict.iteritems():
            if k=="time":
                self.time=v
            else:
                setattr(self, k, v)
        sleep_quotes = ["Sleep, those little slices of death, how I loathe them.",
                                   "No day is so bad it can't be fixed with a nap.",
                                   "People who say they sleep like a baby usually don't have one.",
                                   "Life is too short to sleep on low thread-count sheets",
                                   "Sleep is a symptom of caffeine deprivation.",
                                   "Without enough sleep, we all become tall two-year-olds.",
                                   "I'm not asleep... but that doesn't mean I'm awake.",
                                   "When you have insomnia, you're never really asleep, and you're never really awake.",
                                   "Life is something that happens when you can't get to sleep.",
                                   "Sleeping is no mean art:  for its sake one must stay awake all day.",
                                   "I count it as a certainty that in paradise, everyone naps.",
                                   "Early to rise and early to bed, makes a man healthy and wealthy and dead.",
                                   "I like sleeping, its like death without commitment.",
                                   "I do 5 sit-ups every morning. May not sound like much, but there's only so many times you can hit the snooze button.",
                                   "The early bird gets the worm. The early worm...gets eaten."]
        from random import choice
        if self.funny == "True":
            self.description = choice(sleep_quotes) + "<br><br>Sleeping for " + self.time + " sec."
        else:
            self.description = "Sleeping for " + self.time + " sec."
        self.command = "/bin/sleep " + self.time
        # Timeout needs to be passed to LoggingBuildStep as a kwarg
        self.timeout = 1000
        kwargs['timeout']=self.timeout
        ShellCommand.__init__(self, **kwargs)

    def describe(self, done=False):
        description = ShellCommand.describe(self,done)
        return description