1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 import time
17 from zope.interface import implements
18 from buildbot import interfaces
19 from buildbot.util.eventual import eventually
20
22 implements(interfaces.ISlaveStatus)
23
24 admin = None
25 host = None
26 access_uri = None
27 version = None
28 connected = False
29 graceful_shutdown = False
30
32 self.name = name
33 self._lastMessageReceived = 0
34 self.runningBuilds = []
35 self.graceful_callbacks = []
36 self.connect_times = []
37
51 return self._lastMessageReceived
53 return self.runningBuilds
55 then = time.time() - 3600
56 return len([ t for t in self.connect_times if t > then ])
57
69 self._lastMessageReceived = when
70
72
73 now = time.time()
74 self.connect_times = [ t for t in self.connect_times if t > now - 3600 ] + [ now ]
75
80
85 """Set the graceful shutdown flag, and notify all the watchers"""
86 self.graceful_shutdown = graceful
87 for cb in self.graceful_callbacks:
88 eventually(cb, graceful)
90 """Add watcher to the list of watchers to be notified when the
91 graceful shutdown flag is changed."""
92 if not watcher in self.graceful_callbacks:
93 self.graceful_callbacks.append(watcher)
95 """Remove watcher from the list of watchers to be notified when the
96 graceful shutdown flag is changed."""
97 if watcher in self.graceful_callbacks:
98 self.graceful_callbacks.remove(watcher)
99
113