From patchwork Tue Dec 4 00:08:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 203508 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 354FA2C00AA for ; Tue, 4 Dec 2012 11:08:39 +1100 (EST) Received: from mail-fa0-f73.google.com (mail-fa0-f73.google.com [209.85.161.73]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority" (not verified)) by ozlabs.org (Postfix) with ESMTPS id B698D2C00A5 for ; Tue, 4 Dec 2012 11:08:35 +1100 (EST) Received: by mail-fa0-f73.google.com with SMTP id v1so227197fav.2 for ; Mon, 03 Dec 2012 16:08:32 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=HFG2pADyl3WOOTXoqffcBzgon3C9fbwEZI9Njld9+d8=; b=Ao0agxWWZHte24fYnSl8Sw38dXSbJHEIbEx0N+P1ZFexTHky1OvbXOLLlf12Wf4Ulr 1AR/uU+B+tW9l9VtGA6cieuvezTP35LtFXx0JMxbbPPPeY/3zcHqdIRuUna56VhP+eYA BHPsIEVul6qptlbnnGgx4W+xINPMWNcDCq2P+TfOpXtjr8ZnaNeqI0lhyLyG155+Id+e TQuxv0D/9A22Zk0jnE5gyH5a/1c6BQPFXDpM8EyJl5qZ1f0ahLSMzH4+NWuv+lfQrDaR QdBRRWDUhPfCHH3frKaNw8REh3IPIQYDilXpYuCnLx4gHlELZYAIY9dxZ/Q6wXEKLjW5 HMnQ== Received: by 10.14.208.198 with SMTP id q46mr12169510eeo.0.1354579711884; Mon, 03 Dec 2012 16:08:31 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id u8si3547057een.1.2012.12.03.16.08.31 (version=TLSv1/SSLv3 cipher=AES128-SHA); Mon, 03 Dec 2012 16:08:31 -0800 (PST) Received: from tictac.mtv.corp.google.com (tictac.mtv.corp.google.com [172.22.73.80]) by hpza10.eem.corp.google.com (Postfix) with ESMTP id 853F1200057; Mon, 3 Dec 2012 16:08:31 -0800 (PST) Received: by tictac.mtv.corp.google.com (Postfix, from userid 121310) id D891D80BB1; Mon, 3 Dec 2012 16:08:30 -0800 (PST) From: Doug Anderson To: patchwork@lists.ozlabs.org Subject: [PATCH v2 2/3] pwclient: Handle servers that barf on users with no name Date: Mon, 3 Dec 2012 16:08:18 -0800 Message-Id: <1354579699-26427-2-git-send-email-dianders@chromium.org> X-Mailer: git-send-email 1.7.7.3 In-Reply-To: <1354579699-26427-1-git-send-email-dianders@chromium.org> References: <1354564470-12571-1-git-send-email-dianders@chromium.org> <1354579699-26427-1-git-send-email-dianders@chromium.org> X-Gm-Message-State: ALoCoQnUGfNg0Wi0PUch4JTa8iZDaiIRheV5QXE8ToxSoScfuJRSxEv2YDWZTx+5DUp9syL7s0HavR7ygaxiDu3bZknKmQ1l2K8BgBzFMgpQVZ9KWPOLI6DfIBnfVOyiC8kJjiG72Zjo+uhtjJ4LDxW9XJWtYFYSQewRb1W9uu4ijnN+sI2c1vTr/IGl2Jrm9yAN3tunN67XJNWH6xOjrmSgEiO+gJDJww== Cc: Jeremy Kerr X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.15 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" When working with pwclient I found that the xmlrpc server will barf sometimes if a user has no real name. The server code should be fixed, but also fix the client to handle this more gracefully. Signed-off-by: Doug Anderson --- Changes in v2: - Added return value to handle the non-buggy case. apps/patchwork/bin/pwclient | 36 +++++++++++++++++++++++++++++++++++- 1 files changed, 35 insertions(+), 1 deletions(-) diff --git a/apps/patchwork/bin/pwclient b/apps/patchwork/bin/pwclient index e642195..27bfdb3 100755 --- a/apps/patchwork/bin/pwclient +++ b/apps/patchwork/bin/pwclient @@ -36,6 +36,40 @@ import ConfigParser DEFAULT_URL = "http://patchwork/xmlrpc/" CONFIG_FILES = [os.path.expanduser('~/.pwclientrc')] +class ServerWithFixes(xmlrpclib.Server): + """Wrapper for xmlrpclib.Server that handles some server issues. + + This class adds workarounds for commands that might fail on some versions + of patchwork servers out there. As servers are fixed then workaround + can be removed. + """ + def person_get(self, person_id): + """Fix person_get() to handle people with no real name. + + It appears that if you have a person with no real name then it makes + the server barf (it tries to marshall None but allow_none is False). + If we find this we'll try to grok some info about the user from patches + that he/she sent. + + As an example, the submitter of: + https://patchwork.kernel.org/patch/1668321/ + """ + try: + return self.__getattr__("person_get")(person_id) + except xmlrpclib.Fault, e: + # If it's not the fault we're expecting, pass it on. + if e.faultString != (":cannot marshal " + "None unless allow_none is enabled"): + raise + + # Create a fake person by grabbing the email from one of the patches + patch_list = self.patch_list({'submitter_id': person_id, + 'max_count': 1}) + return { + 'name': '', + 'email': patch_list[0]['submitter'] + } + class Filter: """Filter for selecting patches.""" def __init__(self): @@ -417,7 +451,7 @@ def main(): filt.add("msgid", msgid_str) try: - rpc = xmlrpclib.Server(url, transport = transport) + rpc = ServerWithFixes(url, transport = transport) except: sys.stderr.write("Unable to connect to %s\n" % url) sys.exit(1)