예제 #1
0
파일: metrics.py 프로젝트: ralphbean/bodhi
    def get_widgets(self, release):
        """ Return the metrics for a specified release.

        If our metric widgets are more than a day old, recreate them with
        fresh metrics from our database.
        """
        if self.age and get_age_in_days(self.age) < 1:
            return self.widgets[release]

        log.debug("Generating some fresh metric widgets...")
        freshwidgets = {}
        for rel in Release.select():
            if not rel.metrics:
                log.warning("No metrics found for %s" % rel.name)
                return
            self.init_metrics(rel)
            if not freshwidgets.has_key(rel.name):
                freshwidgets[rel.name] = {}
            for metric in self.metrics:
                widget = metric.get_widget(rel.metrics[metric.__class__.__name__])
                if widget:
                    freshwidgets[rel.name][metric.__class__.__name__] = widget

        self.widgets = freshwidgets
        self.age = datetime.utcnow()
        return self.widgets[release]
예제 #2
0
    def get_widgets(self, release):
        """ Return the metrics for a specified release.

        If our metric widgets are more than a day old, recreate them with
        fresh metrics from our database.
        """
        if self.age and get_age_in_days(self.age) < 1:
            return self.widgets[release]

        log.debug("Generating some fresh metric widgets...")
        freshwidgets = {}
        for rel in Release.select():
            if not rel.metrics:
                log.warning("No metrics found for %s" % rel.name)
                return
            self.init_metrics(rel)
            if not freshwidgets.has_key(rel.name):
                freshwidgets[rel.name] = {}
            for metric in self.metrics:
                widget = metric.get_widget(
                    rel.metrics[metric.__class__.__name__])
                if widget:
                    freshwidgets[rel.name][metric.__class__.__name__] = widget

        self.widgets = freshwidgets
        self.age = datetime.utcnow()
        return self.widgets[release]
예제 #3
0
def nagmail():
    """
    Nag the submitters of updates based on a list of queries
    """
    log.info("Starting nagmail job!")
    queries = [
        ('old_testing',
         PackageUpdate.select(
             AND(PackageUpdate.q.status == 'testing',
                 PackageUpdate.q.request == None)),
         lambda update: update.days_in_testing),
        ('old_pending',
         PackageUpdate.select(
             AND(PackageUpdate.q.status == 'pending',
                 PackageUpdate.q.request == None)),
         lambda update: get_age_in_days(update.date_submitted)),
    ]
    oldname = None
    mail_admin = False
    #mail_proventesters = False

    for name, query, date in queries:
        for update in query:
            if date(update) > 14:
                if update.nagged:
                    if update.nagged.has_key(name) and update.nagged[name]:
                        if (datetime.utcnow() - update.nagged[name]).days < 7:
                            continue  # Only nag once a week at most
                    nagged = update.nagged
                else:
                    nagged = {}

                if update.critpath:
                    if update.critpath_approved:
                        continue
                    else:
                        oldname = name
                        name = 'old_testing_critpath'
                        mail_admin = True
                        #mail_proventesters = True

                log.info("[%s] Nagging %s about %s" %
                         (name, update.submitter, update.title))
                mail.send(update.submitter, name, update)
                if mail_admin:
                    mail.send_admin(name, update)
                    mail_admin = False
                #if mail_proventesters:
                #    mail.send(config.get('proventesters_email'), name, update)
                #    mail_proventesters = False

                nagged[name] = datetime.utcnow()
                update.nagged = nagged

                if oldname:
                    name = oldname
                    oldname = None

    log.info("nagmail complete!")
예제 #4
0
파일: jobs.py 프로젝트: ralphbean/bodhi
def nagmail():
    """
    Nag the submitters of updates based on a list of queries
    """
    log.info("Starting nagmail job!")
    queries = [
            ('old_testing', PackageUpdate.select(
                                    AND(PackageUpdate.q.status == 'testing',
                                        PackageUpdate.q.request == None)),
             lambda update: update.days_in_testing),
            ('old_pending', PackageUpdate.select(
                                    AND(PackageUpdate.q.status == 'pending',
                                        PackageUpdate.q.request == None)),
             lambda update: get_age_in_days(update.date_submitted)),
    ]
    oldname = None
    mail_admin = False
    #mail_proventesters = False

    for name, query, date in queries:
        for update in query:
            if date(update) > 14:
                if update.nagged:
                    if update.nagged.has_key(name) and update.nagged[name]:
                        if (datetime.utcnow() - update.nagged[name]).days < 7:
                            continue # Only nag once a week at most
                    nagged = update.nagged
                else:
                    nagged = {}

                if update.critpath:
                    if update.critpath_approved:
                        continue
                    else:
                        oldname = name
                        name = 'old_testing_critpath'
                        mail_admin = True
                        #mail_proventesters = True

                log.info("[%s] Nagging %s about %s" % (name, update.submitter,
                                                       update.title))
                mail.send(update.submitter, name, update)
                if mail_admin:
                    mail.send_admin(name, update)
                    mail_admin = False
                #if mail_proventesters:
                #    mail.send(config.get('proventesters_email'), name, update)
                #    mail_proventesters = False

                nagged[name] = datetime.utcnow()
                update.nagged = nagged

                if oldname:
                    name = oldname
                    oldname = None

    log.info("nagmail complete!")