From patchwork Wed Nov 6 23:35:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 289072 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from ozlabs.org (localhost [IPv6:::1]) by ozlabs.org (Postfix) with ESMTP id 8D38B2C034A for ; Thu, 7 Nov 2013 11:27:32 +1100 (EST) Received: from mail-ee0-x236.google.com (mail-ee0-x236.google.com [IPv6:2a00:1450:4013:c00::236]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 98F1D2C016A for ; Thu, 7 Nov 2013 10:35:56 +1100 (EST) Received: by mail-ee0-f54.google.com with SMTP id c50so88905eek.41 for ; Wed, 06 Nov 2013 15:35:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=x4DlFjZ36cRMRT8NbabwaNzYh9dqcG9qRkDpYLyEvxE=; b=ystFDO9G81uTXg23wnbr3H2QNNy/UBWEsAt0ECKhLD0SlfhnDbN45AzODYFoWkrGCb 6QEXsXeNDEq6OoDly25cmE+QJt8X5q4Am7ehA4sSx6WRWfi3cLZuF7eXTWPiRjCrYKif W6YIN0g9kWHjkr1HT9W1JCiDz4DvtgAnQ1TqQdvAbCIdYxhsisW3nrjo+z/9zPhngNGG mEe/hm++/wDQjvAHZAcYz2aZ3/7tPqB/VdJjBRMMaDKP3jrg6D27nX+PFcMCw1D5vVYj Oy4nj0xF1+3eDQoQmU+wu1Z3oDWrirwdtjUEz92SBSCxkUebB/MK5QRriTTYsuYkemLm khbw== X-Received: by 10.15.21.133 with SMTP id d5mr571893eeu.121.1383780952372; Wed, 06 Nov 2013 15:35:52 -0800 (PST) Received: from s42.loc (91-119-83-29.dynamic.xdsl-line.inode.at. [91.119.83.29]) by mx.google.com with ESMTPSA id k7sm1598952eeg.13.2013.11.06.15.35.51 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Nov 2013 15:35:51 -0800 (PST) Received: from cow by s42.loc with local (Exim 4.80) (envelope-from ) id 1VeCda-00045R-Qq; Thu, 07 Nov 2013 00:35:50 +0100 From: Bernhard Reutner-Fischer To: patchwork@lists.ozlabs.org Subject: [PATCH] pwclient: catch non-existing hash gracefully Date: Thu, 7 Nov 2013 00:35:36 +0100 Message-Id: <1383780936-15677-1-git-send-email-rep.dot.nop@gmail.com> X-Mailer: git-send-email 1.7.10.4 X-Mailman-Approved-At: Thu, 07 Nov 2013 11:27:22 +1100 Cc: Bernhard Reutner-Fischer , Jeremy Kerr X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.16rc2 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" I was calling view -h deadbeef on the wrong project, silence that and additionally prevent the same thing if the fallback fails. Traceback (most recent call last): File "/home/me/bin/pwclient", line 500, in main() File "/home/me/bin/pwclient", line 427, in main patch_id = patch_id_from_hash(rpc, project_str, hash_str) File "/home/me/bin/pwclient", line 317, in patch_id_from_hash patch = rpc.patch_get_by_project_hash(project, hash) File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__ return self.__send(self.__name, args) File "/usr/lib/python2.7/xmlrpclib.py", line 1578, in __request verbose=self.__verbose File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request return self.parse_response(response) File "/usr/lib/python2.7/xmlrpclib.py", line 1471, in parse_response p.close() File "/usr/lib/python2.7/xmlrpclib.py", line 560, in close self._parser.Parse("", 1) # end of data xml.parsers.expat.ExpatError: no element found: line 1, column 0 Signed-off-by: Bernhard Reutner-Fischer --- apps/patchwork/bin/pwclient | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient index 5fce359..62b7553 100755 --- a/apps/patchwork/bin/pwclient +++ b/apps/patchwork/bin/pwclient @@ -313,12 +313,16 @@ def action_update_patch(rpc, patch_id, state = None, commit = None): sys.stderr.write("Patch not updated\n") def patch_id_from_hash(rpc, project, hash): + patch = {} try: patch = rpc.patch_get_by_project_hash(project, hash) except xmlrpclib.Fault: # the server may not have the newer patch_get_by_project_hash function, # so fall back to hash-only. - patch = rpc.patch_get_by_hash(hash) + try: + patch = rpc.patch_get_by_hash(hash) + except: pass + except: pass if patch == {}: return None