コード例 #1
0
    def fetch(self, patch_ids=None):
        if patch_ids and type(patch_ids) != list:
            _log.error('Error: patch_ids should be a list, found: {}'.format(type(patch_ids)))
            return -1

        if not patch_ids:
            patch_ids = Bugzilla.get_list_of_patches_needing_reviews()
        patch_ids = BugzillaPatchFetcher.filter_valid_patches(patch_ids)
        _log.debug('r? patches: {}'.format(patch_ids))
        Patch.save_patches(patch_ids)
        patches_to_send = self.patches_to_send_to_buildbot(patch_ids)
        _log.info('{} r? patches, {} patches need to be sent to Buildbot.'.format(len(patch_ids), len(patches_to_send)))

        for patch_id in patches_to_send:
            bz_patch = Bugzilla.retrieve_attachment(patch_id)
            if not bz_patch or bz_patch['id'] != patch_id:
                _log.error('Unable to retrive patch "{}"'.format(patch_id))
                continue
            if bz_patch.get('is_obsolete'):
                _log.warn('Patch is obsolete, skipping')
                Patch.set_obsolete(patch_id)
                continue
            rc = Buildbot.send_patch_to_buildbot(bz_patch['path'],
                     properties=['patch_id={}'.format(patch_id), 'bug_id={}'.format(bz_patch['bug_id']), 'owner={}'.format(bz_patch.get('creator', ''))])
            if rc == 0:
                Patch.set_bug_id(patch_id, bz_patch['bug_id'])
                Patch.set_sent_to_buildbot(patch_id)
            else:
                _log.error('Failed to send patch to buildbot.')
                #FIXME: send an email for this failure
        return patch_ids
コード例 #2
0
 def send_patches_to_buildbot(self, patches_to_send, send_to_commit_queue=False):
     if not patches_to_send:
         return
     for patch_id in patches_to_send:
         bz_patch = Bugzilla.retrieve_attachment(patch_id)
         if not bz_patch or bz_patch['id'] != patch_id:
             _log.error('Unable to retrive patch "{}"'.format(patch_id))
             if len(patches_to_send) == 1:
                 return ERR_UNABLE_TO_FETCH_PATCH
             continue
         if bz_patch.get('is_obsolete'):
             _log.warn('Patch is obsolete, skipping')
             Patch.set_obsolete(patch_id)
             if len(patches_to_send) == 1:
                 return ERR_OBSOLETE_PATCH
             continue
         if not send_to_commit_queue and Patch.is_patch_sent_to_buildbot(patch_id):
             _log.error('Patch {} is already sent to buildbot.'.format(patch_id))
             continue
         Patch.set_sent_to_buildbot(patch_id, True, commit_queue=send_to_commit_queue)
         rc = Buildbot.send_patch_to_buildbot(bz_patch['path'],
                  send_to_commit_queue=send_to_commit_queue,
                  properties=['patch_id={}'.format(patch_id), 'bug_id={}'.format(bz_patch['bug_id']), 'owner={}'.format(bz_patch.get('creator', ''))])
         if rc == 0:
             Patch.set_bug_id(patch_id, bz_patch['bug_id'])
         else:
             _log.error('Failed to send patch to buildbot.')
             Patch.set_sent_to_buildbot(patch_id, False, commit_queue=send_to_commit_queue)