예제 #1
0
    def publish(self):
        """Upload the review to Review Board."""
        # Truncate comments to the maximum permitted amount to avoid
        # overloading the review and freezing the browser.
        max_comments = self.settings['max_comments']

        if len(self.comments) > max_comments:
            warning = (
                'WARNING: Number of comments exceeded maximum, showing %d '
                'of %d.'
                % (max_comments, len(self.comments))
            )

            if self.body_top:
                self.body_top = '%s\n%s' % (self.body_top, warning)
            else:
                self.body_top = warning

            del self.comments[max_comments:]

        cleanup_tempfiles()

        bot_reviews = self.api_root.get_extension(
            extension_name='reviewbotext.extension.ReviewBotExtension'
        ).get_review_bot_reviews()

        return bot_reviews.create(
            review_request_id=self.review_request_id,
            body_top=self.body_top,
            body_bottom=self.body_bottom,
            diff_comments=json.dumps(self.comments))
예제 #2
0
파일: review.py 프로젝트: tahnok/ReviewBot
    def publish(self):
        """Upload the review to Review Board."""
        # Truncate comments to the maximum permitted amount to avoid
        # overloading the review and freezing the browser.
        max_comments = self.settings['max_comments']
        if len(self.comments) >  max_comments:
            warning = ("WARNING: Number of comments exceeded maximum, "
                       "showing %d of %d.") % (max_comments, len(self.comments))
            self.body_top = "%s\n%s" % (self.body_top, warning)
            del self.comments[max_comments:]

        cleanup_tempfiles()

        try:
            bot_reviews = self.api_root.get_extension(
                values={
                    'extension_name':
                        'reviewbotext.extension.ReviewBotExtension',
                }).get_review_bot_reviews()
            bot_reviews.create(
                data={
                    'review_request_id': self.request_id,
                    'ship_it': self.ship_it,
                    'body_top': self.body_top,
                    'body_bottom': self.body_bottom,
                    'diff_comments': json.dumps(self.comments),
                })
            return True
        except:
            return False
예제 #3
0
 def publish(self):
     """Upload the review to Review Board."""
     cleanup_tempfiles()
     try:
         bot_reviews = self.api_root.get_extension(
             values={
                 'extension_name':
                     'reviewbotext.extension.ReviewBotExtension',
             }).get_review_bot_reviews()
         bot_reviews.create(
             data={
                 'review_request_id': self.request_id,
                 'ship_it': self.ship_it,
                 'body_top': self.body_top,
                 'body_bottom': self.body_bottom,
                 'diff_comments': json.dumps(self.comments),
             })
         return True
     except:
         return False