Fixed issue with git fetch timeout or server down. 01/62101/1
authorTomasz Olszak <t.olszak@samsung.com>
Mon, 14 Mar 2016 09:37:37 +0000 (10:37 +0100)
committerTomasz Olszak <t.olszak@samsung.com>
Mon, 14 Mar 2016 09:37:37 +0000 (10:37 +0100)
Now in such case emails won't be sent.

Change-Id: I778e7ecef10addb04606ca5bf27a47a82ff3ec71

tool/development/buildbot/nativesamples.py
tool/development/buildbot/poll_and_build_changes.py

index 4a81ea6..94a272a 100644 (file)
@@ -259,7 +259,13 @@ class NativeSamples:
                        if not os.path.exists(nativeSample.projectPath):
                                self._cloneSampleFromGerrit(nativeSample)
                        gitCommandList = ["git", "--git-dir=" + os.path.join(nativeSample.projectPath, ".git")]
-                       fetchOutput = subprocess.check_output(gitCommandList + ["fetch", "origin", "refs/changes/*:refs/remotes/origin/gerrit/*"], stderr=subprocess.STDOUT)
+                       try:
+                               fetchOutput = subprocess.check_output(gitCommandList + ["fetch", "origin", "refs/changes/*:refs/remotes/origin/gerrit/*"], stderr=subprocess.STDOUT)
+                       except subprocess.CalledProcessError as error:
+                               if error.returncode != 128:
+                                       print 'network or server error - trying to fetch next project'
+                               else:
+                                       raise
                        if len(fetchOutput) > 0:
                                print fetchOutput
                        changeIds = re.findall("(?<=-> ).*", fetchOutput)
index a7e3c9c..5c364cb 100755 (executable)
@@ -23,15 +23,19 @@ rootBuildDir =  os.path.abspath(sys.argv[1])
 nativeSamples = ns.NativeSamples(rootBuildDir)
 
 emailSender = ns.EmailSender(nativeSamples.config)
-
+stacktrace = None
 try:
        nativeSamples.pollForChanges()
        nativeSamples.evaluatePendingChanges()
 except KeyboardInterrupt:
        raise
+except subprocess.CalledProcessError as error:
+       stacktrace = "Exception Info:\n\n" + traceback.format_exc() + error.output
+       traceback.print_exc()
 except:
-       subject = 'Tizen SAMPLE BUILD SYSTEM error: Something unexpected happened during build process'
        stacktrace = "Exception Info:\n\n" + traceback.format_exc()
        traceback.print_exc()
-       emailSender.send(mailSubject = subject, mailText = stacktrace)
 
+if stacktrace is not None:
+       subject = 'Tizen SAMPLE BUILD SYSTEM error: Something unexpected happened during build process'
+       emailSender.send(mailSubject = subject, mailText = stacktrace)