Ejemplo n.º 1
0
 def test_get_notify_addresses_projects_match_exactly(self):
     path = os.path.join(self.temp_dir, "production", "notify-addresses")
     with mkfile(path) as f:
         print("ubuntu\[email protected]", file=f)
         print("kubuntu\[email protected]", file=f)
     self.assertEqual(["*****@*****.**"],
                      get_notify_addresses(self.config, "ubuntu"))
     self.assertEqual(["*****@*****.**"],
                      get_notify_addresses(self.config, "kubuntu"))
     self.assertEqual([], get_notify_addresses(self.config, "edubuntu"))
Ejemplo n.º 2
0
 def test_get_notify_addresses_all_matches_any_project(self):
     path = os.path.join(self.temp_dir, "production", "notify-addresses")
     with mkfile(path) as f:
         print("ALL\[email protected] [email protected]", file=f)
     self.assertEqual(["*****@*****.**", "*****@*****.**"],
                      get_notify_addresses(self.config))
     self.assertEqual(["*****@*****.**", "*****@*****.**"],
                      get_notify_addresses(self.config, "ubuntu"))
     self.assertEqual(["*****@*****.**", "*****@*****.**"],
                      get_notify_addresses(self.config, "kubuntu"))
Ejemplo n.º 3
0
def notify_failure(config, log_path):
    if config["DEBUG"] or config["CDIMAGE_NOLOG"]:
        return

    project = config.project
    if config["UBUNTU_DEFAULTS_LOCALE"] == "zh_CN":
        project = "ubuntu-chinese-edition"
    series = config.full_series
    image_type = config.image_type
    date = config["CDIMAGE_DATE"]

    recipients = get_notify_addresses(config, project)
    if not recipients:
        return

    try:
        if log_path is None:
            body = ""
        else:
            body = open(log_path)
        send_mail(
            "CD image %s%s/%s/%s failed to build on %s" % (
                ("(built by %s) " % config["SUDO_USER"]
                 if config["SUDO_USER"] else ""),
                project, series, image_type, date),
            "build-image-set", recipients, body)
    finally:
        if log_path is not None:
            body.close()
Ejemplo n.º 4
0
def live_build_notify_failure(config, arch, lp_build=None):
    if config["DEBUG"]:
        return

    project = config.project
    recipients = get_notify_addresses(config, project)
    if not recipients:
        return

    livefs_id_bits = [project]
    if config.subproject:
        livefs_id_bits.append(config.subproject)
    cpuarch, subarch = split_arch(arch)
    if subarch:
        livefs_id_bits.append(subarch)
    if config["UBUNTU_DEFAULTS_LOCALE"]:
        livefs_id_bits.append(config["UBUNTU_DEFAULTS_LOCALE"])
    livefs_id = "-".join(livefs_id_bits)

    datestamp = time.strftime("%Y%m%d")
    try:
        if lp_build is not None:
            if lp_build.build_log_url is None:
                raise URLError(
                    "Failed build %s has no build_log_url" % lp_build.web_link)
            with closing(urlopen(lp_build.build_log_url, timeout=30)) as comp:
                with closing(io.BytesIO(comp.read())) as comp_bytes:
                    with closing(GzipFile(fileobj=comp_bytes)) as f:
                        body = f.read()
        else:
            log_url = "http://%s/~buildd/LiveCD/%s/%s/latest/livecd-%s.out" % (
                live_builder(config, arch), config.series, livefs_id, cpuarch)
            with closing(urlopen(log_url, timeout=30)) as f:
                body = f.read()
    except URLError:
        body = b""
    subject = "LiveFS %s%s/%s/%s failed to build on %s" % (
        "(built by %s) " % config["SUDO_USER"] if config["SUDO_USER"] else "",
        livefs_id, config.full_series, arch, datestamp)
    send_mail(subject, "buildlive", recipients, body)
Ejemplo n.º 5
0
 def test_get_notify_addresses_no_config(self):
     self.assertEqual([], get_notify_addresses(self.config))