Make Tools/BuildSlaveSupport/wait-for-SVN-server.py handle server donwtime
[WebKit-https.git] / Tools / BuildSlaveSupport / wait-for-SVN-server.py
index f093024a10886f148ca1631c0041f7ecb985842c..bf57ffad5558b29790d421a1c9249d146fefaefa 100755 (executable)
@@ -28,9 +28,14 @@ import subprocess
 
 
 def getLatestSVNRevision(SVNServer):
+    p = subprocess.Popen(["svn", "log", "--non-interactive", "--verbose", "--xml", "--limit=1", SVNServer], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+    response = p.communicate()[0]
+    if p.returncode != 0:
+        print "Can't connect to host: %s, return code %s " % (SVNServer, p.returncode)
+        print "OUTPUT:"
+        print response
+        return -1
     try:
-        p = subprocess.Popen(["svn", "log", "--non-interactive", "--verbose", "--xml", "--limit=1", SVNServer], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-        response = p.communicate()[0]
         doc = xml.dom.minidom.parseString(response)
         el = doc.getElementsByTagName("logentry")[0]
         return el.getAttribute("revision")
@@ -52,7 +57,10 @@ def waitForSVNRevision(SVNServer, revision):
     revision = int(revision)
     while True:
         latestRevision = int(getLatestSVNRevision(SVNServer))
-        if latestRevision < revision:
+        if latestRevision == -1:
+            print "%s SVN server is unreachable. Sleeping for 60 seconds." % (SVNServer)
+            time.sleep(60)
+        elif latestRevision < revision:
             print "Latest SVN revision on %s is r%d, but we are waiting for r%d. Sleeping for 5 seconds." % (SVNServer, latestRevision, revision)
             time.sleep(5)
         else: