diff mbox

[Branch,~linaro-validation/lava-dashboard-tool/trunk] Rev 152: Handle a case when pull fails because of duplicates in another stream

Message ID 20110712131917.16637.1104.launchpad@loganberry.canonical.com
State Accepted
Headers show

Commit Message

Zygmunt Krynicki July 12, 2011, 1:19 p.m. UTC
------------------------------------------------------------
revno: 152
committer: Zygmunt Krynicki <zygmunt.krynicki@linaro.org>
branch nick: trunk
timestamp: Sat 2011-07-09 12:26:59 +0200
message:
  Handle a case when pull fails because of duplicates in another stream
modified:
  lava_dashboard_tool/commands.py


--
lp:lava-dashboard-tool
https://code.launchpad.net/~linaro-validation/lava-dashboard-tool/trunk

You are subscribed to branch lp:lava-dashboard-tool.
To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dashboard-tool/trunk/+edit-subscription
diff mbox

Patch

=== modified file 'lava_dashboard_tool/commands.py'
--- lava_dashboard_tool/commands.py	2011-06-29 09:50:26 +0000
+++ lava_dashboard_tool/commands.py	2011-07-09 10:26:59 +0000
@@ -802,16 +802,20 @@ 
             else:
                 local_bundles = [bundle for bundle in self.server.bundles(stream["pathname"])]
             remote_bundles = [bundle for bundle in self.remote_server.bundles(stream["pathname"])]
-            missing_bundles = set((bundle["content_sha1"] for bundle in remote_bundles)) - set((bundle["content_sha1"] for bundle in local_bundles))
+            missing_bundles = set((bundle["content_sha1"] for bundle in remote_bundles))
+            missing_bundles -= set((bundle["content_sha1"] for bundle in local_bundles))
             try:
-                missing_bytes = sum((bundle["content_size"] for bundle in remote_bundles if bundle["content_sha1"] in missing_bundles))
+                missing_bytes = sum(
+                    (bundle["content_size"]
+                     for bundle in remote_bundles
+                     if bundle["content_sha1"] in missing_bundles))
             except KeyError as ex:
                 # Older servers did not return content_size so this part is optional
                 missing_bytes = None
             if missing_bytes:
                 print "Stream %s needs update (%s)" % (stream["pathname"], self._filesizeformat(missing_bytes))
             elif missing_bundles:
-                print "Stream %s needs update" % (stream["pathname"],)
+                print "Stream %s needs update (no estimate available)" % (stream["pathname"],)
             else:
                 print "Stream %s is up to date" % (stream["pathname"],)
             for content_sha1 in missing_bundles:
@@ -820,8 +824,15 @@ 
                 data = self.remote_server.get(content_sha1)
                 print "got %s, storing" % (self._filesizeformat(len(data["content"]))),
                 sys.stdout.flush()
-                self.server.put(data["content"], data["content_filename"], stream["pathname"])
-                print "done"
+                try:
+                    self.server.put(data["content"], data["content_filename"], stream["pathname"])
+                except xmlrpclib.Fault as ex:
+                    if ex.faultCode == 409:  # duplicate
+                        print "already present (in another stream)"
+                    else:
+                        raise
+                else:            
+                    print "done"
 
 
 class data_views(ExperimentalCommandMixIn, XMLRPCCommand):