comparison bin/sendnotificationmails.py @ 466:e4c0beab5328

Allow sending notifications from a local treepkg via sendnotificationmails.py
author Andre Heinecke <aheinecke@intevation.de>
date Thu, 09 Sep 2010 14:46:13 +0000
parents 1fcdffbeb9de
children a4efa91bc3b2
comparison
equal deleted inserted replaced
465:296d26453e2a 466:e4c0beab5328
18 import treepkgcmd 18 import treepkgcmd
19 from treepkg.readconfig import read_config_section 19 from treepkg.readconfig import read_config_section
20 from treepkg.run import capture_output 20 from treepkg.run import capture_output
21 from treepkg.cmdexpand import cmdexpand 21 from treepkg.cmdexpand import cmdexpand
22 22
23 notification_desc = ["build_user", "build_host", "build_listpending", 23 notification_desc = [("build_user", str, ""), ("build_host", str, ""),
24 "notification_template", 24 "build_listpending", "notification_template",
25 "smtp_host", ("smtp_port", int), 25 "smtp_host", ("smtp_port", int),
26 ] 26 ]
27 27
28 def read_config(filename): 28 def read_config(filename):
29 parser = SafeConfigParser() 29 parser = SafeConfigParser()
54 def send_notification_mails(config_filename): 54 def send_notification_mails(config_filename):
55 config = read_config(config_filename) 55 config = read_config(config_filename)
56 56
57 template = open(config["notification_template"]).read() 57 template = open(config["notification_template"]).read()
58 58
59 lines = capture_output(cmdexpand("ssh $build_user$@$build_host" 59 if not config.get("build_user") or not config.get("build_host"):
60 " $build_listpending", 60 lines = capture_output(cmdexpand("$build_listpending", **config))
61 **config)) 61 else:
62 lines = capture_output(cmdexpand("ssh $build_user$@$build_host"
63 " $build_listpending",
64 **config))
62 for line in lines.splitlines(): 65 for line in lines.splitlines():
63 words = line.split() 66 words = line.split()
64 if len(words) == 4: 67 if len(words) == 4:
65 status, track, revision, rules_revision = words 68 status, track, revision, rules_revision = words
66 values = config.copy() 69 values = config.copy()
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)