Increase default window width to accomodate Build ETA column.
[tpot/bbremote.git] / bbclient.py
1 from twisted.internet import reactor
2 from twisted.cred import credentials
3 from twisted.spread import pb
4 from twisted.python import log
5
6 class BuildbotClient:
7     """A class to manage a remote connection to the buildbot server."""
8
9     def __init__(self):
10
11         self.builders = {}
12         self.remote = None
13         
14     def connect(self, host, port, username, password):
15
16         cf = pb.PBClientFactory()
17         creds = credentials.UsernamePassword(username, password)
18
19         d = cf.login(creds)
20         reactor.connectTCP(host, port, cf)
21
22         d.addCallbacks(self.connected, lambda arg: log.err(arg))
23         
24         log.msg('connecting to %s:%d as %s' % (host, port, username))
25
26         return d
27
28     def connected(self, ref):
29
30         log.msg('connected')
31
32         # Remote reference is a StatusClientPerspective object.
33
34         self.remote = ref
35         self.remote.notifyOnDisconnect(self.disconnected)
36
37     def disconnected(self, ref):
38
39         log.msg('disconnected')
40
41         ref = None        
42
43     def subscribe(self, mode, interval, target):
44         return self.remote.callRemote('subscribe', mode, interval, target)