forked from ericflo/cassbot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_command.py
More file actions
26 lines (22 loc) · 843 Bytes
/
Copy pathbuild_command.py
File metadata and controls
26 lines (22 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from cassbot import BaseBotPlugin
from twisted.web import client, error
from twisted.internet import defer
class BuildCommand(BaseBotPlugin):
build_token = 'xxxxxxxxxxxx'
build_url = 'http://hudson.zones.apache.org/hudson/job'
@defer.inlineCallbacks
def command_build(self, bot, user, channel, args):
if not args:
yield bot.msg(channel, "usage: build <buildname>")
return
url = '%s/%s/polling?token=%s' % (self.build_url, args[0], self.build_token)
msg = "request sent!"
try:
res = yield client.getPage(url)
except error.Error, e:
# Hudson returns a 404 even when this request succeeds :/
if e.status == '404':
pass
else:
msg = str(e)
bot.address_msg(user, channel, msg)