From 14be2b5978fdb20e9de908934d9db82a2f376c96 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Fri, 19 Oct 2012 01:16:29 -0400 Subject: WIP around freedesktop.org problems --- git-bz | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/git-bz b/git-bz index 3e9268d..36b53e0 100755 --- a/git-bz +++ b/git-bz @@ -1273,7 +1273,30 @@ class Bug(object): print "Bug %d - %s" % (self.id, short_desc) print self.get_url() - def create_patch(self, description, comment, filename, data, obsoletes=[], status='none'): + def _patch_via_xmlrpc(self, description, comment, filename, data, obsoletes, status): + params = dict() + params['ids'] = [str(self.id)] + params['data'] = data + params['file_name'] = filename + params['summary'] = description + params['content_type'] = 'text/plain; charset=UTF-8' + params['is_patch'] = '1' + + try: + response = self.server.get_xmlrpc_proxy().Bug.add_attachment(params) + except xmlrpclib.Fault, e: + if "Failed to locate method" in e.faultString: + raise NoXmlRpcError("No add_attachment method") + die(e.faultString) + except xmlrpclib.ProtocolError, e: + if e.errcode == 404: + raise NoXmlRpcError(e.errmsg) + else: + print >>sys.stderr, "Problem creating attachment via XML-RPC: %s (%d)\n" % (e.errmsg, e.errcode) + print >>sys.stderr, "falling back to form post\n" + raise NoXmlRpcError("Communication error") + + def _patch_via_form(self, description, comment, filename, data, obsoletes, status): fields = {} fields['bugid'] = str(self.id) fields['action'] = 'insert' @@ -1299,6 +1322,13 @@ class Bug(object): print response_data die ("Failed to attach patch to bug %d, status=%d" % (self.id, response.status)) + + def create_patch(self, description, comment, filename, data, obsoletes=[], status='none'): + try: + self._patch_via_xmlrpc(description, comment, filename, data, obsoletes, status) + except NoXmlRpcError: + self._patch_via_form(description, comment, filename, data, obsoletes, status) + print "Attached %s" % filename # Update specified fields of a bug; keyword arguments are interpreted -- cgit v1.2.3