job_submitobs: Pylinted
authorEd Bartosh <eduard.bartosh@intel.com>
Tue, 12 Nov 2013 12:39:24 +0000 (14:39 +0200)
committerEd Bartosh <eduard.bartosh@intel.com>
Fri, 15 Nov 2013 19:38:22 +0000 (21:38 +0200)
Change-Id: Ic250816f3d8a091f37d8d30bc448180fb518a927
Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
job_submitobs.py

index a974e7d..1b21542 100755 (executable)
@@ -10,7 +10,6 @@ import tempfile
 import shutil
 import re
 from time import sleep
-import random
 
 # internal module
 from common import runner
@@ -102,8 +101,9 @@ def find_submit_tag(event, mygit):
         if event['branch'] == 'master':
             branch = 'trunk'
         try:
-            tag = mygit.describe(event['patchset_revision'], pattern='submit/%s/*'
-                    % branch, exact_match=True)
+            tag = mygit.describe(event['patchset_revision'],
+                                 pattern='submit/%s/*' % branch,
+                                 exact_match=True)
         except GitRepositoryError:
             # don'n find submit tag on this commit, return None
             tag = None
@@ -163,8 +163,8 @@ def check_tag_format(git, mygerrit, event, tag):
         msg = 'The tag %s was pushed, but it was not completed because of '\
                 'the following reason(s):\n\n' % tag + '\n'.join(message)
 
-        if len(message) != 1 or (message[0] != UNDER_REVIEW_MSG % (tag, psr) and\
-               message[0] != WRONG_COMMIT_MSG % psr):
+        if len(message) != 1 or (message[0] != UNDER_REVIEW_MSG % (tag, psr) \
+           and message[0] != WRONG_COMMIT_MSG % psr):
             msg += '\n\n' + SUGGESTION
 
         mygerrit.review(commit = psr, message = msg)
@@ -272,9 +272,9 @@ def check_obs_project(apiurl, apiuser, apipasswd, obs_prjs):
        return the list of non-exist project
     """
 
-    bs = BuildService(apiurl, apiuser, apipasswd)
+    obs = BuildService(apiurl, apiuser, apipasswd)
 
-    return [prj for prj in set(obs_prjs) if not bs.exists(prj)]
+    return [prj for prj in set(obs_prjs) if not obs.exists(prj)]
 
 def sync_ref(event, git, user, host, port):
     """
@@ -329,12 +329,11 @@ def main():
                              event['event_type']
         return 1
 
-    if os.getenv('SYNC_GERRIT_PROJECT_PATTERN'):
-        # check whether need to sync this project to inside obs
-        r = re.compile(os.getenv('SYNC_GERRIT_PROJECT_PATTERN'))
-        if not r.match(event['project']):
-            print 'Do not need to sync project %s, exit now' % event['project']
-            return 0
+    # check whether need to sync this project
+    pattern = os.getenv('SYNC_GERRIT_PROJECT_PATTERN')
+    if pattern and not re.match(pattern, event['project']):
+        print 'Do not need to sync project %s, exit now' % event['project']
+        return 0
 
     if event['refname'].startswith('refs/changes/'):
         print 'Do not need to process refname %s, exit now' % event['refname']