]> git.pld-linux.org Git - projects/pld-builder.new.git/commitdiff
Try to copy whatever is possible and simply skip (with logging) problematic entries.
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Mon, 5 Oct 2009 15:13:36 +0000 (15:13 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    PLD_Builder/file_sender.py -> 1.31

PLD_Builder/file_sender.py

index 7bafe316031a10d4929c6c584c60633f808cad56..c9b4a495fa03f6f5796f2914345dfd193989b809 100644 (file)
@@ -97,25 +97,27 @@ def post_file(src, url):
     return 0
 
 def send_file(src, target):
-    log.notice("sending %s to %s (size %d bytes)" % (src, target, os.stat(src).st_size))
-    m = re.match('rsync://([^/]+)/.*', target)
-    if m:
-        return rsync_file(src, target, host = m.group(1))
-    if target != "" and target[0] == '/':
-        return copy_file(src, target)
-    m = re.match('scp://([^@:]+@[^/:]+)(:|)(.*)', target)
-    if m:
-        return scp_file(src, m.group(1) + ":" + m.group(3))
-    m = re.match('ssh\+rsync://([^@:]+@[^/:]+)(:|)(.*)', target)
-    if m:
-        return rsync_ssh_file(src, m.group(1) + ":" + m.group(3))
-    m = re.match('http://.*', target)
-    if m:
-        return post_file(src, target)
-    log.alert("unsupported protocol: %s" % target)
-    # pretend everything went OK, so file is removed from queue,
-    # and doesn't cause any additional problems
-    return 0
+    try:
+        log.notice("sending %s to %s (size %d bytes)" % (src, target, os.stat(src).st_size))
+        m = re.match('rsync://([^/]+)/.*', target)
+        if m:
+            return rsync_file(src, target, host = m.group(1))
+        if target != "" and target[0] == '/':
+            return copy_file(src, target)
+        m = re.match('scp://([^@:]+@[^/:]+)(:|)(.*)', target)
+        if m:
+            return scp_file(src, m.group(1) + ":" + m.group(3))
+        m = re.match('ssh\+rsync://([^@:]+@[^/:]+)(:|)(.*)', target)
+        if m:
+            return rsync_ssh_file(src, m.group(1) + ":" + m.group(3))
+        m = re.match('http://.*', target)
+        if m:
+            return post_file(src, target)
+        log.alert("unsupported protocol: %s" % target)
+    except OSError, e:
+        log.error("send_file(%s, %s): %s" % (src, target, e)
+        return False
+    return True
 
 def maybe_flush_queue(dir):
     retry_delay = 0
@@ -159,19 +161,20 @@ def flush_queue(dir):
     q.sort(mycmp)
     
     error = None
-    remaining = q
+    # copy of q
+    remaining = q[:]
     for d in q:
-        if send_file(d['_file'], d['Target']):
+        if not send_file(d['_file'], d['Target']):
             error = d
-            break
+            continue
         if os.access(d['_file'] + ".info", os.F_OK):
-            if send_file(d['_file'] + ".info", d['Target'] + ".info"):
+            if not send_file(d['_file'] + ".info", d['Target'] + ".info"):
                 error = d
-                break
+                continue
             os.unlink(d['_file'] + ".info")
         os.unlink(d['_file'])
         os.unlink(d['_desc'])
-        remaining = q[1:]
+        remaining.remove(d)
         
     if error != None:
         emails = {}
This page took 0.029511 seconds and 4 git commands to generate.