-
Notifications
You must be signed in to change notification settings - Fork 4
/
buildbot.py
executable file
·864 lines (721 loc) · 26.1 KB
/
buildbot.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
#!/usr/bin/python3
from hub import HubBot
import traceback
import itertools
import sys
import os
import select
import threading
import subprocess
import tempfile
import logging
import calendar
import abc
import smtplib
import sleekxmpp.exceptions
from datetime import datetime, timedelta
import email.message
import email.mime.text
import email.mime.multipart
from wsgiref.handlers import format_date_time
logger = logging.getLogger(__name__)
def smtp_insecure(host, port):
return smtplib.SMTP(host, port)
def smtp_ssl(host, port):
return smtplib.SMTP_SSL(host, port)
def smtp_starttls(host, port):
smtp = smtplib.SMTP(host, port)
smtp.starttls()
return smtp
class MailSendConfig(metaclass=abc.ABCMeta):
@classmethod
def _mime_to_bytes(cls, mime):
from io import StringIO
from email.generator import Generator
fp = StringIO()
g = Generator(fp, mangle_from_=False)
g.flatten(mime)
return fp.getvalue()
@abc.abstractmethod
def send_mime_mail(self, mime_mail):
pass
class MailSMTPConfig(MailSendConfig):
SEC_NONE = smtp_insecure
SEC_SSL = smtp_ssl
SEC_STARTTLS = smtp_starttls
def __init__(self, host, port, user, passwd, security=SEC_STARTTLS):
self._host = host
self._port = port
self._user = user
self._passwd = passwd
self._security = security
def send_mime_mail(self, mime_mail, tolist):
smtp = self._security(self._host, self._port)
if self._user is not None:
smtp.login(self._user, self._passwd)
mailbytes = self._mime_to_bytes(mime_mail)
smtp.sendmail(
mime_mail["From"],
tolist,
mailbytes)
smtp.quit()
class MailConfig:
def __init__(self,
mfrom,
sendconfig,
subject="[buildbot] {severity}: {project} -- {target}"):
super().__init__()
self._mfrom = mfrom
self._sendconfig = sendconfig
self._subject = subject
def send_mail(self, lines, severity, project, target, tolist):
mail = email.mime.multipart.MIMEMultipart()
mail["To"] = ", ".join(tolist)
mail["From"] = self._mfrom
mail["Date"] = format_date_time(
calendar.timegm(datetime.utcnow().utctimetuple()))
mail["Subject"] = self._subject.format(
severity=severity,
project=project,
target=target)
text = """
Hello,
This is buildbot. This is a status notification for the job
{project} / {target}
The job has the status: {severity}.
Please see the attached output log for details and take appropriate
action.""".format(
severity=severity,
project=project,
target=target)
mime_text = email.mime.text.MIMEText(
text.encode("utf-8"), _charset="utf-8")
mail.attach(mime_text)
mime_log = email.mime.text.MIMEText(
"\n".join(lines).encode("utf-8"), _charset="utf-8")
mime_log.add_header(
"Content-Disposition",
"attachment",
filename="job.log")
mail.attach(mime_log)
self._sendconfig.send_mime_mail(mail, tolist)
class Popen(subprocess.Popen):
DEVNULLR = open("/dev/null", "r")
@classmethod
def checked(cls, call, *args, **kwargs):
proc = cls(call, *args, **kwargs)
result = proc.communicate()
retval = proc.wait()
if retval != 0:
raise subprocess.CalledProcessError(retval, " ".join(call))
return result
def __init__(self, call, *args, sink_line_call=None, update_env={}, **kwargs):
if sink_line_call is not None:
kwargs["stdout"] = subprocess.PIPE
kwargs["stderr"] = subprocess.PIPE
if "stdin" not in kwargs:
kwargs["stdin"] = self.DEVNULLR
if update_env:
env = os.environ
env.update(update_env)
kwargs["env"] = env
super().__init__(call, *args, **kwargs)
self.sink_line_call = sink_line_call
if sink_line_call is not None:
sink_line_call("$ {cmd}".format(cmd=" ".join(call)).encode())
def _submit_buffer(self, buf, force=False):
if b"\n" not in buf:
if force:
self.sink_line_call(buf)
return b""
else:
return buf
split = buf.split(b"\n")
for line in split[:-1]:
# discard everything before the last carriage return
line = line.split(b"\r")[-1]
self.sink_line_call(line)
return split[-1]
def communicate(self):
if self.sink_line_call is not None:
rlist = set([self.stdout, self.stderr])
buffers = {
self.stdout: b"",
self.stderr: b""
}
while True:
rs, _, _ = select.select(rlist, [], [])
for fd in rs:
fno = fd.fileno()
read = fd.readline()
if len(read) == 0:
rlist.remove(fd)
buf = buffers[fd]
if len(buf):
self._submit_buffer(buf, True)
del buffers[fd]
continue
buffers[fd] += read
buffers[fd] = self._submit_buffer(buffers[fd])
if len(rlist) == 0:
break
for buf in buffers:
self._submit_buffer(buf, True)
return None, None
else:
return super().communicate()
class WorkingDirectory:
def __init__(self, path):
self.path = path
def __enter__(self):
self.old_pwd = os.getcwd()
os.chdir(self.path)
return self.path
def __exit__(self, exc_type, exc_value, traceback):
os.chdir(self.old_pwd)
del self.old_pwd
return False
class Target:
def __init__(self, name, branch):
super().__init__()
self.name = name
self.branch = branch
def __str__(self):
return self.name
class Respawn(Target):
initial_cwd = os.getcwd()
class Forward:
def __init__(self, to_jid, msg="respawn", mtype="chat", **kwargs):
super().__init__(**kwargs)
self.to_jid = to_jid
self.msg = msg
self.mtype = mtype
def do_forward(self, xmpp):
xmpp.send_message(
mto=self.to_jid,
mbody=self.msg,
mtype=self.mtype
)
def __init__(self, name, xmpp,
branch="master",
forwards=[],
**kwargs):
super().__init__(name, branch, **kwargs)
self.xmpp = xmpp
self.forwards = forwards
self.cwd = os.getcwd()
@classmethod
def exec_respawn(cls, xmpp):
xmpp.disconnect(reconnect=False, wait=True)
try:
os.chdir(cls.initial_cwd)
os.execv(sys.argv[0], sys.argv)
except:
print("during execv")
traceback.print_exc()
raise
def build(self, log_func):
xmpp = self.xmpp
for forward in self.forwards:
log_func("Sending respawn command to {0}".format(forward.to_jid).encode())
forward.do_forward(xmpp)
log_func("Respawning self".encode())
self.exec_respawn(xmpp)
def __str__(self):
return "respawn {}".format(self.name)
class Execute(Target):
def __init__(self, name, *commands,
working_directory=None,
branch="master",
update_env={},
**kwargs):
super().__init__(name, branch, **kwargs)
self.working_directory = working_directory
self.commands = commands
self.update_env = update_env
def _do_build(self, log_func):
def checked(*args, **kwargs):
return Popen.checked(*args, sink_line_call=log_func, **kwargs)
for command in self.commands:
checked(command, update_env=self.update_env)
def build(self, log_func):
wd = self.working_directory or os.getcwd()
with WorkingDirectory(wd):
self._do_build(log_func)
class Pull(Execute):
class Mode:
def __init__(self, remote_location, log_func):
self.remote_location = remote_location
self.log_func = log_func
def checked(self, *args, **kwargs):
return Popen.checked(*args, sink_line_call=self.log_func, **kwargs)
class Rebase(Mode):
def run(self):
log_func, checked = self.log_func, self.checked
output = subprocess.check_output(["git", "stash"])
stashed = b"No local changes to save\n" != output
try:
call = ["git", "pull", "--rebase"]
if self.remote_location:
call.extend(self.remote_location)
checked(call)
except subprocess.CalledProcessError:
# pull failed, this is quite bad
log_func("pull failed, trying to restore previous state.".encode())
if stashed:
log_func("NOTE: There is a stash which needs to be un-stashed!".encode())
raise
if stashed:
checked(["git", "stash", "pop"])
class Merge(Mode):
def run(self):
log_func, checked = self.log_func, self.checked
try:
call = ["git", "pull"]
if self.remote_location:
call.extend(self.remote_location)
checked(call)
except subprocess.CalledProcessError:
# pull failed
log_func("pull failed, repository remains unchanged")
raise
def __init__(self, name, repository_location, branch,
after_pull_commands=[],
remote_location=None,
mode=Merge):
super().__init__(name, *after_pull_commands,
working_directory=repository_location)
self.remote_location = remote_location
self.branch = branch
self.mode = mode
def _do_build(self, log_func):
self.mode(self.remote_location, log_func).run()
super()._do_build(log_func)
output = subprocess.check_output(["git", "log", "--oneline", "HEAD^..HEAD"]).decode().strip()
log_func("{0} is now at {1}".format(self.name, output).encode())
def __str__(self):
return "pull {0}".format(self.name)
class Build(Execute):
def __init__(self, name, *args,
submodules=[],
commands=["make"],
working_copy=None,
pull=True,
**kwargs):
super().__init__(name, *commands, **kwargs)
self.submodules = submodules
self.working_copy = working_copy
self.pull = pull
def build_environment(self, log_func):
return self.project.build_environment(
log_func,
self.branch,
self.submodules,
working_copy=self.working_copy,
pull=self.pull
)
def _do_build(self, env):
def checked(*args, **kwargs):
return Popen.checked(*args, sink_line_call=env.log_func, **kwargs)
for command in self.commands:
checked(command)
def build(self, log_func):
with self.build_environment(log_func) as env:
self._do_build(env)
def __str__(self):
return "build {0}".format(self.name)
class BuildAndMove(Build):
def __init__(self, *args, move_to=None, move_from=None, **kwargs):
super().__init__(*args, **kwargs)
if not move_to:
raise ValueError("Required parameter move_to missing or empty.")
self.move_to = move_to
self.move_from = move_from
def _do_build(self, env):
def checked(*args, **kwargs):
return Popen.checked(*args, sink_line_call=env.log_func, **kwargs)
super()._do_build(env)
if self.move_from is not None:
move_from = self.move_from.format(
builddir=env.tmp_dir
)
else:
move_from = env.tmp_dir
checked(["rsync", "-raHAPSEXy", "--delete-after", move_from, self.move_to])
class BuildEnvironment:
def __init__(self, tmp_dir, repo_url, branch, submodules, log_func, pull=True):
self.tmp_dir_context = None
self.tmp_dir = tmp_dir
self.repo_url = repo_url
self.branch = branch
self.submodules = submodules
self.log_func = log_func
self.pull = pull
def __enter__(self):
def checked(*args, **kwargs):
return Popen.checked(*args, sink_line_call=self.log_func, **kwargs)
if self.tmp_dir is None:
self.tmp_dir_context = tempfile.TemporaryDirectory()
self.tmp_dir = self.tmp_dir_context.name
try:
if not os.path.isdir(self.tmp_dir):
os.makedirs(self.tmp_dir)
os.chdir(self.tmp_dir)
if os.path.isdir(os.path.join(self.tmp_dir, ".git")):
checked(["git", "fetch", "-t", "origin"])
else:
checked(["git", "clone", self.repo_url, self.tmp_dir])
checked(["git", "checkout", self.branch])
if self.pull:
checked(["git", "pull"])
for submodule in self.submodules:
checked(["git", "submodule", "init", submodule])
checked(["git", "submodule", "update", submodule])
except:
if self.tmp_dir_context is not None:
self.tmp_dir_context.cleanup()
self.tmp_dir_context = None
raise
return self
def __exit__(self, exc_type, exc_value, traceback):
if self.tmp_dir_context is not None:
self.tmp_dir_context.cleanup()
return False
class Project:
@classmethod
def declare(cls, name, *args, **kwargs):
return (name, cls(name, *args, **kwargs))
def __init__(self, name, *builds,
repository_url=None,
pubsub_name=None,
working_copy=None,
mail_on_error=None,
**kwargs):
super().__init__(**kwargs)
self.name = name
self.repository_url = repository_url
self.pubsub_name = pubsub_name
self.working_copy = working_copy
self.builds = builds
self.mail_on_error = mail_on_error
for build in self.builds:
build.project = self
if pubsub_name is not None:
triggers = {}
for build in self.builds:
build_list = triggers.setdefault((self.pubsub_name, build.branch), [])
build_list.append(build)
self.triggers = triggers
else:
self.triggers = {}
def build_environment(self, log_func, branch, submodules,
working_copy=None,
**kwargs):
return BuildEnvironment(
working_copy or self.working_copy,
self.repository_url,
branch,
submodules,
log_func,
**kwargs
)
def __str__(self):
return self.name
class IOHandler:
class IOCapture:
def __init__(self, handler):
self._handler = handler
self._lines = []
def _handle_line(self, line):
self._lines.append(line)
def __enter__(self):
self._handler.add_line_hook(self._handle_line)
return self
def __exit__(self, exc_type, exc_value, traceback):
self._handler.remove_line_hook(self._handle_line)
@property
def lines(self):
return self._lines
def __init__(self):
self._line_hooks = []
def add_line_hook(self, line_hook):
self._line_hooks.append(line_hook)
def remove_line_hook(self, line_hook):
self._line_hooks.remove(line_hook)
def capture(self):
return self.IOCapture(self)
def write_line(self, line):
for hook in self._line_hooks:
hook(line)
class BuildBot(HubBot):
GIT_NODE = "git@"+HubBot.FEED
IDLE_MESSAGE = "constructor waiting for instructions"
config_credentials = {}
nickname = "foo"
def __init__(self, config_path):
self._config_path = config_path
self.initialized = False
error = self.reloadConfig()
if error:
traceback.print_exception(*error)
sys.exit(1)
self.initialized = True
credentials = self.config_credentials
super().__init__(
credentials["localpart"],
credentials["resource"],
credentials["password"]
)
del credentials["password"]
nickname = credentials["nickname"]
self.notification_to = credentials["notify"]
self.switch, self.nick = self.addSwitch(credentials["channel"], nickname, self.build_switch)
self.bots_switch, _ = self.addSwitch("bots", nickname)
self.add_event_handler("pubsub_publish", self.pubsubPublish)
self.output_handler = IOHandler()
def _muc_output(self, line):
self.send_message(
mto=self.switch,
mbody=line,
mtype="groupchat"
)
def _setup_pubsub(self):
try:
iq = self.pubsub.get_subscriptions(self.FEED, self.GIT_NODE)
if len(iq["pubsub"]["subscriptions"]) == 0:
self.pubsub.subscribe(self.FEED, self.GIT_NODE, bare=True)
except sleekxmpp.exceptions.IqError:
# error'd
self.send_message(
mto=self.bots_switch,
mbody="failed to setup pubsub link",
mtype="groupchat"
)
# this is the return value for the scheduler (i.e. run
# again)
return True
return False
def sessionStart(self, event):
super().sessionStart(event)
if self._setup_pubsub():
self.scheduler.add(
"link-pubsub",
60.0,
self._setup_pubsub,
repeat=True)
self.send_message(mto=self.switch,
mbody="",
msubject=self.IDLE_MESSAGE,
mtype="groupchat"
)
def reloadConfig(self):
namespace = {}
with open(self._config_path, "r") as f:
conf = f.read()
global_namespace = dict(globals())
global_namespace["xmpp"] = self
try:
exec(conf, global_namespace, namespace)
except Exception:
return sys.exc_info()
new_credentials = namespace.get("credentials", {})
if "localpart" not in new_credentials or "password" not in new_credentials:
raise ValueError("Both localpart and password must be present in credentials.")
if "nickname" not in new_credentials:
new_credentials["nickname"] = new_credentials["localpart"]
if "resource" not in new_credentials:
new_credentials["resource"] = "core"
# don't respawn on new password -- it'll get updated on next connect
# anyways
cmp_creds_new = dict(new_credentials)
del cmp_creds_new["password"]
cmp_creds_old = dict(self.config_credentials)
if cmp_creds_new != cmp_creds_old and self.initialized:
logger.info("Respawning due to major config change")
Respawn.exec_respawn(self)
self.config_credentials = new_credentials
self.authorized = set(namespace.get("authorized", []))
self.blacklist = set()
self.projects = dict(namespace.get("projects", []))
# repobranch-map contains the following structure
#
# {(repo, branch) => {project => [builds]}}
self.repobranch_map = {}
for project in self.projects.values():
for repobranch, builds in project.triggers.items():
projectmap = self.repobranch_map.setdefault(
repobranch, {})
projectmap[project] = list(builds)
return None
def build_switch(self, msg):
pass
def broadcast_error(self, msg, build, err):
hint = "Project “{0}”, target “{1!s}” is broken, traceback logged to {2}".format(
build.project.name,
build,
self.switch
)
self.send_message(
mto=self.bots_switch,
mbody="{1}: {0}".format(hint, self.notification_to),
mtype="groupchat"
)
self.send_message(
mto=self.switch,
mbody=self.format_exception(err),
mtype="groupchat"
)
print(hint)
def mail_error(self, severity, project, build, err, output_lines):
if project.mail_on_error is None:
print("project doesn't have configured mail foo")
return
print("sending mail")
mailconf, tolist = project.mail_on_error
mailconf.send_mail(
output_lines,
severity,
project.name,
build.name,
tolist)
def rebuild_repo(self, msg, repo, branch):
repobranch = (repo, branch)
try:
projects = self.repobranch_map[repobranch]
except KeyError:
raise
for project, builds in projects.items():
self.rebuild_project_subset(msg, project, builds)
return True
def rebuild_project_subset(self, msg, project, builds):
try:
for build in builds:
with self.output_handler.capture() as capture:
self.rebuild(build)
except subprocess.CalledProcessError as err:
self.broadcast_error(msg, build, err)
self.mail_error("failure", project, build, err, capture.lines)
return False
except Exception as err:
self.broadcast_error(msg, build, err)
self.mail_error("error", project, build, err, capture.lines)
return False
finally:
self.send_message(
mto=self.switch,
mbody="",
msubject=self.IDLE_MESSAGE,
mtype="groupchat"
)
def pubsubPublish(self, msg):
item = msg["pubsub_event"]["items"]["item"].xml[0]
repo = item.findtext("{http://hub.sotecware.net/xmpp/git-post-update}repository")
if repo is None:
print("Malformed git-post-update.")
ref = item.findtext("{http://hub.sotecware.net/xmpp/git-post-update}ref")
if ref is None:
print("Malformed git-post-update.")
try:
self.rebuild_repo(msg, repo, ref.split("/")[2])
except KeyError:
pass
def format_exception(self, exc_info):
return "\n".join(traceback.format_exception(*sys.exc_info()))
def reply_exception(self, msg, exc_info):
self.reply(msg, self.format_exception(exc_info))
def authorizedSource(self, msg):
origin = str(msg["from"].bare)
if not origin in self.authorized:
if not origin in self.blacklist:
self.reply(msg, "You're not authorized.")
self.blacklist.add(origin)
return False
return True
def messageMUC(self, msg):
if msg["mucnick"] == self.nick:
return
contents = msg["body"].strip()
if contents == "ping":
self.reply(msg, "pong")
return
def message(self, msg):
if msg["type"] == "groupchat":
return
if not self.authorizedSource(msg):
return
contents = msg["body"]
args = contents.split(" ", 1)
cmd = args[0]
args = args[1] if len(args) > 1 else ""
handler = self.COMMANDS.get(cmd, None)
if handler is not None:
try:
local = {"__func": handler, "__self": self, "__msg": msg}
self.reply(msg, repr(eval("__func(__self, __msg, {0})".format(args), globals(), local)))
except Exception:
self.reply_exception(msg, sys.exc_info())
else:
self.reply(msg, "Unknown command: {0}".format(cmd))
def rebuild(self, build):
def log_func_binary(buf):
if not isinstance(buf, str):
buf = buf.decode(errors="replace")
msg = buf.strip()
if msg:
self.output_handler.write_line(msg)
project = build.project
topic = "Running: {project!s} – {build!s}".format(
project=project,
build=build
)
self.send_message(mto=self.switch, mbody="", msubject=topic, mtype="groupchat")
self.output_handler.write_line(topic)
self.output_handler.add_line_hook(self._muc_output)
try:
build.build(log_func_binary)
self.output_handler.write_line("done.")
finally:
self.output_handler.remove_line_hook(self._muc_output)
def cmdRebuild(self, msg, projectName):
project = self.projects.get(projectName, None)
if not project:
return "Unknown project: {0}".format(projectName)
self.rebuild(project)
return True
def cmdReload(self, msg):
result = self.reloadConfig()
if result:
self.reply_exception(msg, result)
else:
return True
def cmdRebuildRepo(self, msg, repository, branch):
try:
self.rebuild_repo(msg, repository, branch)
except KeyError:
self.reply(msg, "Repository-branch combination not tracked: {}".format((repository, branch)))
def cmdEcho(self, msg, *args):
return " ".join((str(arg) for arg in args))
COMMANDS = {
"rebuild": cmdRebuild,
"rebuild-repo": cmdRebuildRepo,
"reload": cmdReload,
"echo": cmdEcho
}
if __name__=="__main__":
try:
import setproctitle
setproctitle.setproctitle("constructor")
except ImportError:
pass
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
"-c", "--config-file",
default="buildbot_config.py",
help="Path to the config file to use.",
dest="config_file"
)
args = parser.parse_args()
del parser
buildbot = BuildBot(args.config_file)
buildbot.run()