Ejemplo n.º 1
0
    def scan_for_image_tasks(self):
        results = [ ]

        # Trigger based on how old the youngest issue is
        for image, wait_time in self.scan_image_wait_times().items():
            if wait_time <= 0:
                results.append(GitHub.TaskEntry(BASELINE_PRIORITY, GithubImageTask("refresh-" + image,
                                                                                   image,
                                                                                   DEFAULT_IMAGE_REFRESH[image],
                                                                                   None)))

        # Trigger on explicit requests

        def issue_requests_image_refresh(issue, comments, image):
            request = "bot: " + ISSUE_TITLE_IMAGE_REFRESH.format(image)
            in_process_prefix = "Image creation for {} in process".format(image)

            needed = False
            for body in [ issue['body'] ] + [ c['body'] for c in comments ]:
                if body == request:
                    needed = True
                if body.startswith(in_process_prefix):
                    needed = False
            return needed

        for issue in self.get("issues?labels=bot&state=open"):
            comments = self.get(issue['comments_url'])
            for image in DEFAULT_IMAGE_REFRESH:
                if issue_requests_image_refresh(issue, comments, image):
                    results.append(GitHub.TaskEntry(BASELINE_PRIORITY, GithubImageTask("refresh-" + image,
                                                                                       image,
                                                                                       DEFAULT_IMAGE_REFRESH[image],
                                                                                       issue)))

        return results
Ejemplo n.º 2
0
 def scan_for_image_tasks(self):
     results = []
     for image, wait_time in self.scan_image_wait_times().items():
         if wait_time <= 0:
             results.append(
                 GitHub.TaskEntry(
                     BASELINE_PRIORITY,
                     GithubImageTask("refresh-" + image, image,
                                     DEFAULT_IMAGE_REFRESH[image])))
     return results
Ejemplo n.º 3
0
    def scan_for_image_tasks(self):
        issues = self.get("issues?labels=bot&filter=all&state=all")

        results = []
        for image, config in DEFAULT_IMAGE_REFRESH.items():
            found = False
            for issue in issues:
                if issue['title'] == ISSUE_TITLE_IMAGE_REFRESH.format(image):
                    age = time.time() - time.mktime(
                        time.strptime(issue['created_at'],
                                      "%Y-%m-%dT%H:%M:%SZ"))
                    if age < IMAGE_REFRESH * 24 * 60 * 60:
                        found = True
            if not found:
                results.append(
                    GitHub.TaskEntry(
                        BASELINE_PRIORITY,
                        GithubImageTask("refresh-" + image, image, config)))

        return results