From 3eed4abc28a0eb994904197578813cd1d8181b22 Mon Sep 17 00:00:00 2001 From: Tomasz Olszak Date: Mon, 14 Mar 2016 10:37:37 +0100 Subject: [PATCH] Fixed issue with git fetch timeout or server down. Now in such case emails won't be sent. Change-Id: I778e7ecef10addb04606ca5bf27a47a82ff3ec71 --- tool/development/buildbot/nativesamples.py | 8 +++++++- tool/development/buildbot/poll_and_build_changes.py | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tool/development/buildbot/nativesamples.py b/tool/development/buildbot/nativesamples.py index 4a81ea6..94a272a 100644 --- a/tool/development/buildbot/nativesamples.py +++ b/tool/development/buildbot/nativesamples.py @@ -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) diff --git a/tool/development/buildbot/poll_and_build_changes.py b/tool/development/buildbot/poll_and_build_changes.py index a7e3c9c..5c364cb 100755 --- a/tool/development/buildbot/poll_and_build_changes.py +++ b/tool/development/buildbot/poll_and_build_changes.py @@ -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) -- 2.7.4