Ejemplo n.º 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))
Ejemplo n.º 2
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))
            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
Ejemplo n.º 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