Package buildbot :: Package clients :: Module sendchange
[frames] | no frames]

Source Code for Module buildbot.clients.sendchange

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16   
17  from twisted.spread import pb 
18  from twisted.cred import credentials 
19  from twisted.internet import reactor 
20   
21 -class Sender:
22 - def __init__(self, master, auth=('change','changepw'), encoding='utf8'):
23 self.username, self.password = auth 24 self.host, self.port = master.split(":") 25 self.port = int(self.port) 26 self.encoding = encoding
27
28 - def send(self, branch, revision, comments, files, who=None, category=None, 29 when=None, properties={}, repository='', vc=None, project='', 30 revlink='', codebase=None):
31 change = {'project': project, 'repository': repository, 'who': who, 32 'files': files, 'comments': comments, 'branch': branch, 33 'revision': revision, 'category': category, 'when': when, 34 'properties': properties, 'revlink': revlink, 'src': vc} 35 36 # codebase is only sent if set; this won't work with masters older than 37 # 0.8.7 38 if codebase: 39 change['codebase'] = codebase 40 41 for key in change: 42 if type(change[key]) == str: 43 change[key] = change[key].decode(self.encoding, 'replace') 44 change['files'] = list(change['files']) 45 for i, file in enumerate(change.get('files', [])): 46 if type(file) == str: 47 change['files'][i] = file.decode(self.encoding, 'replace') 48 49 f = pb.PBClientFactory() 50 d = f.login(credentials.UsernamePassword(self.username, self.password)) 51 reactor.connectTCP(self.host, self.port, f) 52 53 def call_addChange(remote): 54 d = remote.callRemote('addChange', change) 55 d.addCallback(lambda res: remote.broker.transport.loseConnection()) 56 return d
57 d.addCallback(call_addChange) 58 59 return d
60