Пример #1
0
    def notify(self, cr_dict):
        self.cr_dict = cr_dict
        cr = CodeReview(self.env, cr_dict['cr_id'])
        
        cursor = self.env.get_db_cnx().cursor()
        cursor.execute("SELECT author, message FROM revision WHERE rev='%s'" % cr_dict['cr_id'])

        recordset = cursor.fetchall()

        if not recordset:
            return
        cs_author = recordset[0][0]
        cs_message = recordset[0][1]

        if cs_author == "anonymous" and cr_dict['cr_author'] == "anonymous":
            return

        subject = "[TracNotify] ChangeSet r%s by %s reviewed by %s" % \
                  (cr_dict['cr_id'], cs_author, ','.join(cr.get_reviewers()))
        if cr_dict['priority'] == 'critical':
            subject = '[Critical]' + subject

        ticket_info = self.get_ticket_info(cs_message, cr_dict['cr_message'])

        self.hdf['trac_name'] = self.env.config.get('project', 'name')
        absurl = self.env.config.get('codereview', 'absurl')
        self.hdf['absurl'] = absurl
        self.hdf['r_content'] = wiki_to_html(cr_dict['cr_message'], self.env, cr_dict['req'], absurls = absurl)
        self.hdf['ticket_len'] = len(ticket_info)
        self.hdf['t_info'] = ticket_info
        self.hdf['cs_id'] = cr_dict['cr_id']
        self.hdf['cs_author'] = cs_author
        self.hdf['cs_message'] = wiki_to_html(cs_message, self.env, cr_dict['req'], absurls = absurl, escape_newlines=True)
        self.hdf['r_author'] = ', '.join(cr.get_reviewers())
        self.hdf['r_priority'] = cr_dict['priority']

        self.subject = subject

        self.smtp_server = self.config['notification'].get('smtp_server')
        self.smtp_port = self.config['notification'].getint('smtp_port')
        self.from_email = self.config['notification'].get('smtp_from')
        self.replyto_email = self.config['notification'].get('smtp_replyto')
        self.from_email = self.from_email or self.replyto_email
        if not self.from_email and not self.replyto_email:
            raise TracError(Markup('Unable to send email due to identity '
                                   'crisis.<p>Neither <b>notification.from</b> '
                                   'nor <b>notification.reply_to</b> are '
                                   'specified in the configuration.</p>'),
                            'SMTP Notification Error')

        # Authentication info (optional)
        self.user_name = self.config['notification'].get('smtp_user')
        self.password = self.config['notification'].get('smtp_password')

        Notify.notify(self, cr_dict['cr_id'])
Пример #2
0
    def notify(self, cr_dict):
        self.cr_dict = cr_dict
        cr = CodeReview(self.env, cr_dict['cr_id'])
        
        cursor = self.env.get_db_cnx().cursor()
        cursor.execute("SELECT author, message FROM revision WHERE rev='%s'" % cr_dict['cr_id'])

        recordset = cursor.fetchall()

        if not recordset:
            return
        cs_author = recordset[0][0]
        cs_message = recordset[0][1]

        if cs_author == "anonymous" and cr_dict['cr_author'] == "anonymous":
            return

        subject = "[TracNotify] ChangeSet r%s by %s reviewed by %s" % \
                  (cr_dict['cr_id'], cs_author, ','.join(cr.get_reviewers()))
        if cr_dict['priority'] == 'critical':
            subject = '[Critical]' + subject

        ticket_info = self.get_ticket_info(cs_message, cr_dict['cr_message'])

        self.hdf['trac_name'] = self.env.config.get('project', 'name')
        absurl = self.env.config.get('codereview', 'absurl')
        self.hdf['absurl'] = absurl
        self.hdf['r_content'] = wiki_to_html(cr_dict['cr_message'], self.env, cr_dict['req'], absurls = absurl)
        self.hdf['ticket_len'] = len(ticket_info)
        self.hdf['t_info'] = ticket_info
        self.hdf['cs_id'] = cr_dict['cr_id']
        self.hdf['cs_author'] = cs_author
        self.hdf['cs_message'] = wiki_to_html(cs_message, self.env, cr_dict['req'], absurls = absurl, escape_newlines=True)
        self.hdf['r_author'] = ', '.join(cr.get_reviewers())
        self.hdf['r_priority'] = cr_dict['priority']

        self.subject = subject

        self.smtp_server = self.config['notification'].get('smtp_server')
        self.smtp_port = self.config['notification'].getint('smtp_port')
        self.from_email = self.config['notification'].get('smtp_from')
        self.replyto_email = self.config['notification'].get('smtp_replyto')
        self.from_email = self.from_email or self.replyto_email
        if not self.from_email and not self.replyto_email:
            raise TracError(Markup('Unable to send email due to identity '
                                   'crisis.<p>Neither <b>notification.from</b> '
                                   'nor <b>notification.reply_to</b> are '
                                   'specified in the configuration.</p>'),
                            'SMTP Notification Error')

        # Authentication info (optional)
        self.user_name = self.config['notification'].get('smtp_user')
        self.password = self.config['notification'].get('smtp_password')

        Notify.notify(self, cr_dict['cr_id'])
Пример #3
0
 def notify(self, cr_dict):
     self.cr_dict = cr_dict
     cr_id = cr_dict['cr_id']
     cr = CodeReview(self.env, cr_id)
     reviewers = ", ".join(cr.get_reviewers())
     api_key = self.env.config.get("codereview", "sender_api_key")
     xmlrpcserver = self.env.config.get("codereview", "bamboo_xmlrpc_server")
     bamboo_enabled = self.env.config.get("codereview", "bamboo_enabled")
     absurl = self.env.config.get("codereview", "absurl")
     db = self.env.get_db_cnx()
     cursor = db.cursor()
     cursor.execute("SELECT author from revision where rev=%s" % (str(cr_id), ))
     cs_author = cursor.fetchone()
     if cs_author:
         cs_author = cs_author[0]
     else:
         return
     if absurl.endswith("/"):
         absurl = absurl[:-1]
     if api_key and xmlrpcserver and bamboo_enabled == "true":
         try:
             server = xmlrpclib.ServerProxy(xmlrpcserver)
             server.add_update(int(api_key), \
                 "Revision %s has been reviewed by %s. %s/CodeReview/%s" % \
                               (cr_id, reviewers, absurl, cr_id), 
                               [cs_author,])
         except Exception, error_info:
             self.env.log.error(error_info)
Пример #4
0
 def notify(self, cr_dict):
     self.cr_dict = cr_dict
     cr_id = cr_dict['cr_id']
     cr = CodeReview(self.env, cr_id)
     reviewers = ", ".join(cr.get_reviewers())
     api_key = self.env.config.get("codereview", "sender_api_key")
     xmlrpcserver = self.env.config.get("codereview", "bamboo_xmlrpc_server")
     bamboo_enabled = self.env.config.get("codereview", "bamboo_enabled")
     absurl = self.env.config.get("codereview", "absurl")
     db = self.env.get_db_cnx()
     cursor = db.cursor()
     cursor.execute("SELECT author from revision where rev=%s" % (str(cr_id), ))
     cs_author = cursor.fetchone()
     if cs_author:
         cs_author = cs_author[0]
     else:
         return
     if absurl.endswith("/"):
         absurl = absurl[:-1]
     if api_key and xmlrpcserver and bamboo_enabled == "true":
         try:
             server = xmlrpclib.ServerProxy(xmlrpcserver)
             server.add_update(int(api_key), \
                 "Revision %s has been reviewed by %s. %s/CodeReview/%s" % \
                               (cr_id, reviewers, absurl, cr_id), 
                               [cs_author,])
         except Exception, error_info:
             self.env.log.error(error_info)
Пример #5
0
 def get_recipients(self, cr_id):
     cr = CodeReview(self.env, cr_id)
     reviewers = list(set(self.get_reviewer_team() + cr.get_reviewers()))
     cr_author = cr['author']
     if cr_author in reviewers:
         reviewers.remove(cr_author)
     return ([cr_author,], reviewers)
Пример #6
0
    def get_recipients(self, cr_id):
        cr = CodeReview(self.env, cr_id)
        reviewers = list(set(self.get_reviewer_team() + cr.get_reviewers()))

	cs_author = self.hdf.get('cs_author', None)
	if cs_author is None:
            cursor = self.env.get_db_cnx().cursor()
            cursor.execute("SELECT author FROM revision WHERE rev='%s'" % cr_id)
            cs_author = cursor.fetchone()
            if cs_author:
                cs_author = cs_author[0]
            else:
	        cs_author = ''

        if cs_author in reviewers:
            reviewers.remove(cs_author)
        return ([cs_author,], reviewers)
Пример #7
0
    def get_recipients(self, cr_id):
        cr = CodeReview(self.env, cr_id)
        reviewers = list(set(self.get_reviewer_team() + cr.get_reviewers()))

        cs_author = self.hdf.get('cs_author', None)
        if cs_author is None:
            cursor = self.env.get_db_cnx().cursor()
            cursor.execute("SELECT author FROM revision WHERE rev='%s'" %
                           cr_id)
            cs_author = cursor.fetchone()
            if cs_author:
                cs_author = cs_author[0]
            else:
                cs_author = ''

        if cs_author in reviewers:
            reviewers.remove(cs_author)
        return ([
            cs_author,
        ], reviewers)