Fix compat issue with older OBS, fix email send bug in request
authorHasan Wan <hasan.wan@intel.com>
Fri, 7 Sep 2012 05:16:19 +0000 (13:16 +0800)
committerHasan Wan <hasan.wan@intel.com>
Fri, 7 Sep 2012 05:17:54 +0000 (13:17 +0800)
Change-Id: Iae48f86f6b3ce9fbd272c9cc03e1b215e6b141d0
Signed-off-by: Hasan Wan <hasan.wan@intel.com>
job_buildcheck.py
job_request.py
requests/mailer.py

index f8c98a1..1d47653 100755 (executable)
@@ -41,6 +41,7 @@ envparas = ['JENKINS_HOME',
             'OBS_API_URL',
             'OBS_OSCRC_PATH',
             'MAPPING_PRJ',
+            'NOREPLY_EMAIL_SENDER',
             'GIT_CACHE_DIR']
 export(envparas, locals())
 
index 427a5ab..1589430 100755 (executable)
@@ -3,6 +3,7 @@ from common.envparas import export
 from common import git
 from common import buildservice
 from common.gerrit import Gerrit
+from common.send_mail import prepare_mail
 from requests.mailer import mailer
 
 import json
@@ -211,9 +212,7 @@ def notify_submiter(event_fields, data):
                         MAILINGLIST.split(','), BCC_MAILS, data,  SR_ENABLE_USER, EMAIL_TEMPLATES_DIR)
     print status
     if status:
-        with codecs.open('%s.env' %(BUILD_TAG), mode='w', encoding='utf-8') as f:
-            for key in status.keys():
-                f.write('%s=%s\n' %(key, status[key]))
+        prepare_mail("%s.env" %(BUILD_TAG), status['subject'], status['body'], NOREPLY_EMAIL_SENDER, status['To'])
 
 event = json.loads(' '.join(OBS_EVENT_STRING.split()))
 event_fields = event['fields']['obsEvent']
index ded70f6..c8dfcaf 100644 (file)
@@ -55,17 +55,6 @@ MAIL_TRIGGERS = {
                 'tgtprj': 'deleteproject',
              },
              {
-                'temp':  'obs_request_maintainer',
-                'cond':  lambda bs, req: req['role'] and req['person'],
-                'sub':   '${reqid}: Maintainer request for ${targetproject}/${targetpackage}',
-                'to':    ['mailinglist'],
-                'cc':    ['who'],
-                'from':  'who',
-                'fields':['description', 'targetproject', 'targetpackage', 'role', 'person'],
-                'detail?':False,
-                'tgtprj': 'targetproject',
-             },
-             {
                 'temp':  'obs_request_changedevel',
                 'cond':  lambda bs, req: req['origintype'] == 'change_devel',
                 'sub':   '${reqid}: Change devel of ${targetproject}/${targetpackage} to ${sourceproject}/${sourcepackage}',
@@ -102,28 +91,6 @@ MAIL_TRIGGERS = {
         'OBS_SRCSRV_REQUEST_ACCEPTED':
             (
              {
-                'temp':  'obs_request_maintainer_accept',
-                'cond':  lambda bs, req: req['state'] == 'accepted' and req['role'] and req['person'],
-                'sub':   '${reqid} accepted: ${role} request for ${targetproject}/${targetpackage}',
-                'to':    ['author', 'person'],
-                'cc':    ['mailinglist'],
-                'from':  'sender',
-                'fields':['comment', 'targetproject', 'targetpackage', 'role', 'person'],
-                'detail?':False,
-                'tgtprj': 'targetproject',
-             },
-             {
-                'temp':  'obs_request_delpkg_accept',
-                'cond':  lambda bs, req: req['state'] == 'accepted' and req['deleteproject'] and req['deletepackage'],
-                'sub':   '${reqid} accepted: ${deleteproject}/${deletepackage} was deleted',
-                'to':    ['author'],
-                'cc':    ['mailinglist'],
-                'from':  'sender',
-                'fields':['comment', 'deleteproject', 'deletepackage'],
-                'detail?':False,
-                'tgtprj': 'deleteproject',
-             },
-             {
                 'temp':  'obs_request_changedevel_accept',
                 'cond':  lambda bs, req: req['state'] == 'accepted' and req['origintype'] == 'change_devel',
                 'sub':   '${reqid} accepted: ${sourceproject}/${sourcepackage} is devel of ${targetproject}/${targetpackage}',
@@ -149,17 +116,6 @@ MAIL_TRIGGERS = {
         'OBS_SRCSRV_REQUEST_STATECHANGE':
             (
              {
-                'cond':  lambda bs, req: req['state'] == 'declined' and req['role'] and req['person'],
-                'temp':  'obs_request_maintainer_decline',
-                'sub':   '${reqid} declined: Request to maintain ${targetproject}/${targetpackage}',
-                'to':    ['author'],
-                'cc':    ['mailinglist'],
-                'from':  'sender',
-                'fields':['comment', 'targetproject', 'targetpackage', 'role', 'person'],
-                'detail?':False,
-                'tgtprj': 'targetproject',
-             },
-             {
                 'cond':  lambda bs, req: req['state'] == 'declined' and req['deleteproject'] and req['deletepackage'],
                 'temp':  'obs_request_delpkg_decline',
                 'sub':   '${reqid} declined: Request to delete ${deleteproject}/${deletepackge}',
@@ -204,17 +160,6 @@ MAIL_TRIGGERS = {
                 'tgtprj': 'targetproject',
              },
              {
-                'cond':  lambda bs, req: req['state'] == 'revoked' and req['role'] and req['person'],
-                'temp':  'obs_request_maintainer_revoke',
-                'sub':   '${reqid} revoked: Request to maintain ${targetproject}/${targetpackage}',
-                'to':    ['mailinglist'],
-                'cc':    [],
-                'from':  'who',
-                'fields':['comment', 'targetproject', 'targetpackage', 'role', 'person'],
-                'detail?':False,
-                'tgtprj': 'targetproject',
-             },
-             {
                 'cond':  lambda bs, req: req['state'] == 'revoked' and req['deleteproject'] and req['deletepackage'],
                 'temp':  'obs_request_delpkg_revoke',
                 'sub':   '${reqid} revoked: Request to delete ${deleteproject}/${deletepackage}',
@@ -342,6 +287,6 @@ def mailer(request, bs, wi, noreply_sender, ml, bccs, request_data,
             from string import Template
             template = Template(template_str)
             body = template.safe_substitute(return_dict, msg="\n".join(msg))
-        return_dict['body'] = body.replace('\n','\\n')
+        return_dict['body'] = body
 
     return return_dict