Fix several bugs:
authorHasan Wan <hasan.wan@intel.com>
Wed, 22 Aug 2012 06:38:26 +0000 (14:38 +0800)
committerLin Yang <lin.a.yang@intel.com>
Tue, 28 Aug 2012 03:23:08 +0000 (11:23 +0800)
1. Unicode issues when wirting to file as envs
2. Remove update git ops, supposed that git tree are latest, because git pull
   will lead to failed if called in parallel
3. Remove Debug Env settings
4. Handle the char ':' in git subject when split the key-value by it

Change-Id: I605aca812cd88c8a2e49adf7efe52a90c432a5d2
Signed-off-by: Hasan Wan <hasan.wan@intel.com>
request.py

index 2c0641c..427a5ab 100644 (file)
@@ -9,6 +9,7 @@ import json
 import sys
 import os
 import datetime
+import codecs
 
 envparas = ['OBS_EVENT_STRING',
             'OBS_OSCRC_PATH',
@@ -36,8 +37,6 @@ def request_url(request_id):
 
 def tag_info(prjdir, tag):
 
-    git.update_git_project(GIT_CACHE_DIR, prjdir, GIT_URL)
-
     gitprj = git.Git(os.path.join(GIT_CACHE_DIR,prjdir))
     if gitprj.find_tag(tag):
         return gitprj.get_tag(tag)
@@ -88,11 +87,11 @@ def OBS_Git_data(event_fields):
         entry = {}
         for line in section.split('\n'):
             try:
-                key, value = line.split(':')
+                key, value = line.split(':',1)
                 entry[mapping[key.strip()]] = value.strip()
             except:
-                print '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
-                print 'key:value  %s:%s' %(key, value)
+                print '-------------------------------------'
+                print 'key:value  %s' %(line)
                 pass
 
         tag = tag_info(entry['git_project'], entry['git_tag'])
@@ -212,11 +211,9 @@ def notify_submiter(event_fields, data):
                         MAILINGLIST.split(','), BCC_MAILS, data,  SR_ENABLE_USER, EMAIL_TEMPLATES_DIR)
     print status
     if status:
-        with open('%s.env' %(BUILD_TAG),'w') as f:
-            for a in status.keys():
-                f.write('%s=%s\n' %(a, status[a]))
-
-GIT_URL="git://gerrit2.bj.intel.com"
+        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]))
 
 event = json.loads(' '.join(OBS_EVENT_STRING.split()))
 event_fields = event['fields']['obsEvent']