-
Notifications
You must be signed in to change notification settings - Fork 0
/
bordel.py
119 lines (96 loc) · 4.49 KB
/
bordel.py
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/usr/bin/python
# -*- python -*-
import shlex
from buildbot import interfaces
from buildbot.sourcestamp import SourceStamp
from buildbot.process.base import BuildRequest
from buildbot.process.properties import Properties
from buildbot.status.words import IRC, IRCContact, IrcStatusBot, IrcBuildRequest
from PySideConf import config
from PySideConf import metadata
class PySideContact(IRCContact):
def command_ORDER(self, args, who):
modules = [module.name for module in metadata.BuildPackages]
response = who + ', the build order is: ' + ', '.join(modules)
self.send(response)
command_ORDER.usage = 'order - tells in which order the modules are built'
def command_CUSTOMERS(self, args, who):
names = config.gitCustomers.keys()
last = names.pop()
names = ', '.join(names)
if names:
names += ' and '
txt = 's are '
else:
txt = ' is '
names += last
string = who + ', my customer' + txt + names
self.send(string)
def command_BUILD(self, args, who):
args = shlex.split(args)
repos = { 'apiextractor' : None,
'generatorrunner' : None,
'shiboken' : None,
'pyside' : None
}
if not who in config.gitCustomers:
self.send('%s, I\'ll not make this build for you. Do you think I found my genitalia in the trash?' % who)
return
builder = None
for arg in args:
try:
repo, target = arg.split('=')
except:
self.send('Usage: ' + PySideContact.command_BUILD.usage)
return
if repo == 'builder':
builder = target
else:
if not repo in repos:
self.send('%s, there\'s no "%s" repository' % (who, repo))
return
repos[repo] = target
slaves = ['build-pyside-' + arch for arch in config.slavesByArch.keys()]
if builder:
if builder not in slaves:
self.send("%s, the slave '%s' that you asked for doesn't exist." % (who, builder))
return
slaves = [builder]
for which in slaves:
bc = self.getControl(which)
build_properties = Properties()
build_properties.setProperty('owner', who, 'Build requested from IRC bot on behalf of %s.' % who)
for propName, propValue in [(pName, pValue) for pName, pValue in repos.items() if pValue]:
build_properties.setProperty(propName + '_hashtag', propValue, 'Build requested from IRC bot.')
for repoName, gitUrl in config.gitCustomers[who].items():
build_properties.setProperty(repoName.lower() + '_gitUrl', config.baseGitURL + gitUrl,
'Personal %s repository of %s.' % (repoName, who))
r = "forced: by %s: %s" % (self.describeUser(who), 'He had his reasons.')
s = SourceStamp(branch='BRANCH', revision='REVISION')
req = BuildRequest(r, s, which, properties=build_properties)
try:
bc.requestBuildSoon(req)
except interfaces.NoSlaveError:
self.send("%s, sorry, I can't force a build: all slaves are offline" % who)
return
ireq = IrcBuildRequest(self)
req.subscribe(ireq.started)
command_BUILD_USAGE = " [builder=<BUILDER_NAME>] [apiextractor=<HASH|TAG|BRANCH>] [generatorrunner=<HASH|TAG|BRANCH>] [shiboken=<HASH|TAG|BRANCH>] [pyside=<HASH|TAG|BRANCH>]... - builds the whole PySide toolchain for the user's repositories; if any of them is omitted the buildbot will use origin/master."
command_BUILD.usage = "build" + command_BUILD_USAGE
def command_BUILDA(self, args, who):
self.command_BUILD(args, who)
command_BUILDA.usage = "builda" + command_BUILD_USAGE
def command_COMPILA(self, args, who):
self.command_BUILD(args, who)
command_COMPILA.usage = "compila" + command_BUILD_USAGE
def watchedBuildFinished(self, b):
if 'owner' in b.properties:
self.send('%s, check this out:' % b.properties['owner'])
IRCContact.watchedBuildFinished(self, b)
IrcStatusBot.contactClass = PySideContact
class Meretriz(IRC):
def __init__(self):
IRC.__init__(self,
host=config.ircServerName,
nick='meretriz',
channels=['#bordel'])