Exemplo n.º 1
0
    def __deserialize(self, queueName, filePath):
        try:
            queue = open(filePath, "r")
        except IOError:
            return

        for line in queue.readlines():
            if not line.startswith("#"):
                for path in line.strip().split():
                    if not os.path.exists(path):
                        # Try to guess absolute path from package name
                        try:
                            component = InstallDB().get_package(path).partOf
                        except:
                            continue
    
                        if component:
                            path = "%s/%s/%s/pspec.xml" % (utils.get_local_repository_url(), component.replace(".", "/"), path)
    
                            if os.path.exists(path):
                                queueName.append(path)
                    else:
                        queueName.append(path)

        queue.close()
Exemplo n.º 2
0
    def __deserialize(self, queueName, fileName):
        try:
            queue = open(os.path.join(conf.buildfarmdir, fileName), "r")
        except IOError:
            return

        for line in queue.readlines():
            if not line.startswith("#"):
                line = line.strip()
                if not os.path.exists(line):
                    # Try to guess absolute path from package name
                    try:
                        component = InstallDB().get_package(line).partOf
                    except:
                        continue

                    if component:
                        path = "%s/%s/%s/pspec.xml" % (
                            utils.get_local_repository_url(),
                            component.replace(".", "/"), line)

                        if os.path.exists(path):
                            queueName.append(path)
                else:
                    queueName.append(line)

        queue.close()
Exemplo n.º 3
0
    def __init__(self, pspeclist, rdresolv=True):

        self.resolvrdeps = rdresolv

        self.oldwd = os.getcwd()
        os.chdir(utils.get_local_repository_url())

        # Work queue and wait queue may contain same pspecs.
        # be sure that every pspec is unique in the pspeclist.
        self.pspeclist = [pspec for pspec in set(pspeclist)]

        self.bdepmap, self.rdepmap, self.namemap, self.srcnamemap, self.pspeccount = {}, {}, {}, {}, len(self.pspeclist)

        for pspec in self.pspeclist:
            if len(pspec.split()) == 1:
                self.bdepmap[pspec] = self.__getBuildDependencies(pspec)
            else:
                for path in pspec.split():
                    try:
                        self.bdepmap[pspec] += self.__getBuildDependencies(
                            path)
                    except KeyError:
                        self.bdepmap[pspec] = self.__getBuildDependencies(path)
                self.bdepmap[pspec] = list(set(self.bdepmap[pspec]))
                for path in pspec.split():
                    for pkg in self.__getPackageNames(path):
                        if pkg in self.bdepmap[pspec]:
                            self.bdepmap[pspec].remove(pkg)
        for pspec in self.pspeclist:
            if len(pspec.split()) == 1:
                self.rdepmap[pspec] = self.__getRuntimeDependencies(pspec)
            else:
                for path in pspec.split():
                    try:
                        self.rdepmap[pspec] += self.__getRuntimeDependencies(
                            path)
                    except KeyError:
                        self.rdepmap[pspec] = self.__getRuntimeDependencies(
                            path)
        for pspec in self.pspeclist:
            if len(pspec.split()) == 1:
                self.namemap[pspec] = self.__getPackageNames(pspec)
                self.srcnamemap[pspec] = self.__getSrcName(pspec)
            else:
                for path in pspec.split():
                    try:
                        self.namemap[pspec] += self.__getPackageNames(path)
                        self.srcnamemap[pspec] += self.__getSrcName(path)
                    except KeyError:
                        self.namemap[pspec] = self.__getPackageNames(path)
                        self.srcnamemap[pspec] = self.__getSrcName(path)
Exemplo n.º 4
0
    def __init__(self, pspeclist):

        self.oldwd = os.getcwd()
        os.chdir(utils.get_local_repository_url())

        # Work queue and wait queue may contain same pspecs.
        # be sure that every pspec is unique in the pspeclist.
        self.pspeclist = [pspec for pspec in set(pspeclist)]

        self.bdepmap, self.rdepmap, self.namemap, self.pspeccount = {}, {}, {}, len(self.pspeclist)

        for pspec in self.pspeclist:
            self.bdepmap[pspec] = self.__getBuildDependencies(pspec)
        for pspec in self.pspeclist:
            self.rdepmap[pspec] = self.__getRuntimeDependencies(pspec)
        for pspec in self.pspeclist:
            self.namemap[pspec] = self.__getPackageNames(pspec)
Exemplo n.º 5
0
    def __init__(self, pspeclist, rdresolv = True):

        self.resolvrdeps = rdresolv

        self.oldwd = os.getcwd()
        os.chdir(utils.get_local_repository_url())

        # Work queue and wait queue may contain same pspecs.
        # be sure that every pspec is unique in the pspeclist.
        self.pspeclist = [pspec for pspec in set(pspeclist)]

        self.bdepmap, self.rdepmap, self.namemap, self.srcnamemap, self.pspeccount = {}, {}, {}, {}, len(self.pspeclist)

        for pspec in self.pspeclist:
            if len(pspec.split()) == 1: self.bdepmap[pspec] = self.__getBuildDependencies(pspec)
            else:
                for path in pspec.split():
                    try:
                        self.bdepmap[pspec] += self.__getBuildDependencies(path)
                    except KeyError:
                        self.bdepmap[pspec] = self.__getBuildDependencies(path)
                self.bdepmap[pspec] = list(set(self.bdepmap[pspec]))
                for path in pspec.split():
                    for pkg in self.__getPackageNames(path):
                        if pkg in self.bdepmap[pspec]: self.bdepmap[pspec].remove(pkg)
        for pspec in self.pspeclist:
            if len(pspec.split()) == 1: self.rdepmap[pspec] = self.__getRuntimeDependencies(pspec)
            else:
                for path in pspec.split():
                    try:
                        self.rdepmap[pspec] += self.__getRuntimeDependencies(path)
                    except KeyError:
                        self.rdepmap[pspec] = self.__getRuntimeDependencies(path)
        for pspec in self.pspeclist:
            if len(pspec.split()) == 1:
                self.namemap[pspec] = self.__getPackageNames(pspec)
                self.srcnamemap[pspec] = self.__getSrcName(pspec)                
            else:
                for path in pspec.split():
                    try:
                        self.namemap[pspec] += self.__getPackageNames(path)
                        self.srcnamemap[pspec] += self.__getSrcName(path)                
                    except KeyError:
                        self.namemap[pspec] = self.__getPackageNames(path)
                        self.srcnamemap[pspec] = self.__getSrcName(path)
Exemplo n.º 6
0
    def __init__(self, pspeclist):

        self.oldwd = os.getcwd()
        os.chdir(utils.get_local_repository_url())

        # Work queue and wait queue may contain same pspecs.
        # be sure that every pspec is unique in the pspeclist.
        self.pspeclist = [pspec for pspec in set(pspeclist)]

        self.bdepmap, self.rdepmap, self.namemap, self.pspeccount = {}, {}, {}, len(
            self.pspeclist)

        for pspec in self.pspeclist:
            self.bdepmap[pspec] = self.__getBuildDependencies(pspec)
        for pspec in self.pspeclist:
            self.rdepmap[pspec] = self.__getRuntimeDependencies(pspec)
        for pspec in self.pspeclist:
            self.namemap[pspec] = self.__getPackageNames(pspec)
Exemplo n.º 7
0
def send(msg, pspec = "", _type = "", subject=""):

    if not conf.sendemail:
        logger.info("Sending of notification e-mails is turned off.")
        return


    # Authentication stuff
    (username, password) = Auth().get_credentials("Mailer")

    # subjectID: ex: [release/{devel,stable}/arch]
    subject_id = "%s/%s/%s" % (conf.release.capitalize(),
                               conf.subrepository,
                               conf.architecture)

    logs_dir = "%s/%s/%s" % (conf.release,
                             conf.subrepository,
                             conf.architecture)


    recipients_name, recipients_email = [], []
    last_updater_name, last_updater_email = "", "" 
    logfilename = ""
    package_name_with_component = ""
    package_name = ""
    last_log = []
    if pspec:
        spec = pisi.specfile.SpecFile(os.path.join(utils.get_local_repository_url(), pspec))
        recipients_name.append(spec.source.packager.name)
        recipients_email.append(spec.source.packager.email)
        last_updater_name = spec.history[0].name
        last_updater_email = spec.history[0].email

        package_name = os.path.basename(os.path.dirname(pspec))
        package_name_with_component = utils.get_package_component_path(pspec)

        logfile = os.path.join(utils.get_package_log_directory(),
                               utils.get_package_logfile_name(pspec))
        logfilename = os.path.splitext(os.path.basename(logfile))[0]

        last_log = open(logfile.replace(".txt", ".log")).read().split("\n")[-50:]

        if _type == "check": package_name_with_component = ""

    message = templates.ALL[_type] % {
                                        'log'          : "\n".join(last_log),
                                        'recipientName': " ".join(recipients_name),
                                        'mailTo'       : ", ".join(recipients_email),
                                        'updaterName'  : last_updater_name,
                                        'mailToUpdater': last_updater_email,
                                        'ccList'       : conf.cclist,
                                        'mailFrom'     : conf.mailfrom,
                                        'announceAddr' : conf.announceaddr,
                                        'subject'      : package_name_with_component or subject or _type,
                                        'message'      : msg,
                                        'pspec'        : pspec,
                                        'type'         : _type,
                                        'packagename'  : package_name,
                                        'logfilename'  : logfilename,
                                        'distribution' : conf.name,
                                        'release'      : conf.release.capitalize(),
                                        'arch'         : conf.architecture,
                                        'logsdir'      : logs_dir,
                                        'subjectID'    : subject_id,
                                     }

    try:
        session = smtplib.SMTP(conf.smtpserver, timeout=10)
    except smtplib.SMTPConnectError:
        logger.error("Failed sending e-mail: Couldn't open session on %s." % conf.smtpserver)
        return

    try:
        session.login(username, password)
    except smtplib.SMTPAuthenticationError:
        logger.error("Failed sending e-mail: Authentication failed.")
        return

    try:
        if _type == "announce":
            session.sendmail(conf.mailfrom, conf.announceaddr, message)
        else:
            session.sendmail(conf.mailfrom, recipients_email + conf.cclist.split(","), message)
    except smtplib.SMTPException:
        logger.error("Failed sending e-mail: sendmail() raised an exception.")
Exemplo n.º 8
0
def send(msg, pspec="", _type="", subject=""):

    if not conf.sendemail:
        logger.info("Sending of notification e-mails is turned off.")
        return

    # Authentication stuff
    (username, password) = Auth().get_credentials("Mailer")

    # subjectID: ex: [release/{devel,stable}/arch]
    subject_id = "%s/%s/%s" % (conf.release.capitalize(), conf.subrepository,
                               conf.architecture)

    logs_dir = "%s/%s/%s" % (conf.release, conf.subrepository,
                             conf.architecture)

    recipients_name, recipients_email = [], []
    last_updater_name, last_updater_email = "", ""
    logfilename = ""
    package_name_with_component = ""
    package_name = ""
    last_log = []
    if pspec:
        spec = pisi.specfile.SpecFile(
            os.path.join(utils.get_local_repository_url(), pspec))
        recipients_name.append(spec.source.packager.name)
        recipients_email.append(spec.source.packager.email)
        last_updater_name = spec.history[0].name
        last_updater_email = spec.history[0].email

        package_name = os.path.basename(os.path.dirname(pspec))
        package_name_with_component = utils.get_package_component_path(pspec)

        logfile = os.path.join(utils.get_package_log_directory(),
                               utils.get_package_logfile_name(pspec))
        logfilename = os.path.splitext(os.path.basename(logfile))[0]

        last_log = open(logfile.replace(".txt",
                                        ".log")).read().split("\n")[-50:]

        if _type == "check": package_name_with_component = ""

    message = templates.ALL[_type] % {
        'log': "\n".join(last_log),
        'recipientName': " ".join(recipients_name),
        'mailTo': ", ".join(recipients_email),
        'updaterName': last_updater_name,
        'mailToUpdater': last_updater_email,
        'ccList': conf.cclist,
        'mailFrom': conf.mailfrom,
        'announceAddr': conf.announceaddr,
        'subject': package_name_with_component or subject or _type,
        'message': msg,
        'pspec': pspec,
        'type': _type,
        'packagename': package_name,
        'logfilename': logfilename,
        'distribution': conf.name,
        'release': conf.release.capitalize(),
        'arch': conf.architecture,
        'logsdir': logs_dir,
        'subjectID': subject_id,
    }

    try:
        session = smtplib.SMTP(conf.smtpserver, timeout=10)
    except smtplib.SMTPConnectError:
        logger.error("Failed sending e-mail: Couldn't open session on %s." %
                     conf.smtpserver)
        return

    try:
        session.login(username, password)
    except smtplib.SMTPAuthenticationError:
        logger.error("Failed sending e-mail: Authentication failed.")
        return

    try:
        if _type == "announce":
            session.sendmail(conf.mailfrom, conf.announceaddr, message)
        else:
            session.sendmail(conf.mailfrom,
                             recipients_email + conf.cclist.split(","),
                             message)
    except smtplib.SMTPException:
        logger.error("Failed sending e-mail: sendmail() raised an exception.")