From patchwork Tue Jul 12 13:19:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zygmunt Krynicki X-Patchwork-Id: 2670 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id DAC0823F51 for ; Tue, 12 Jul 2011 13:19:21 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 8E6DBA1832D for ; Tue, 12 Jul 2011 13:19:21 +0000 (UTC) Received: by qwb8 with SMTP id 8so3355050qwb.11 for ; Tue, 12 Jul 2011 06:19:21 -0700 (PDT) Received: by 10.229.68.200 with SMTP id w8mr4959129qci.114.1310476759327; Tue, 12 Jul 2011 06:19:19 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.217.78 with SMTP id hl14cs242315qcb; Tue, 12 Jul 2011 06:19:18 -0700 (PDT) Received: by 10.227.10.210 with SMTP id q18mr5384352wbq.44.1310476757968; Tue, 12 Jul 2011 06:19:17 -0700 (PDT) Received: from adelie.canonical.com (adelie.canonical.com [91.189.90.139]) by mx.google.com with ESMTP id fm12si28090435wbb.50.2011.07.12.06.19.17; Tue, 12 Jul 2011 06:19:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) client-ip=91.189.90.139; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.139 as permitted sender) smtp.mail=bounces@canonical.com Received: from loganberry.canonical.com ([91.189.90.37]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1Qgcrt-0001Hu-Cd for ; Tue, 12 Jul 2011 13:19:17 +0000 Received: from loganberry.canonical.com (localhost [127.0.0.1]) by loganberry.canonical.com (Postfix) with ESMTP id 5D9B52E8014 for ; Tue, 12 Jul 2011 13:19:17 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dashboard-tool X-Launchpad-Branch: ~linaro-validation/lava-dashboard-tool/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 152 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [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> Date: Tue, 12 Jul 2011 13:19:17 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="13388"; Instance="initZopeless config overlay" X-Launchpad-Hash: 8cc8c32de7446b0069c7bfcdb0ae9977519d5e43 ------------------------------------------------------------ revno: 152 committer: Zygmunt Krynicki 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 === 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):