Merge lp:~fourdollars/ubuntu/vivid/python-debianbts/1512200 into lp:ubuntu/vivid/python-debianbts

Proposed by Shih-Yuan Lee
Status: Merged
Merge reported by: Sebastien Bacher
Merged at revision: not available
Proposed branch: lp:~fourdollars/ubuntu/vivid/python-debianbts/1512200
Merge into: lp:ubuntu/vivid/python-debianbts
Diff against target: 132 lines (+50/-14)
4 files modified
debian/changelog (+6/-0)
debian/control (+3/-2)
src/debianbts.py (+27/-12)
test/test_debianbts.py (+14/-0)
To merge this branch: bzr merge lp:~fourdollars/ubuntu/vivid/python-debianbts/1512200
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Review via email: mp+276359@code.launchpad.net

Description of the change

This patch is from https://github.com/venthur/python-debianbts/pull/5/files.
Please help to sponsor this patch.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2014-07-07 14:50:29 +0000
+++ debian/changelog 2015-11-02 06:35:16 +0000
@@ -1,3 +1,9 @@
1python-debianbts (1.12ubuntu0.1) vivid-proposed; urgency=medium
2
3 * Fix the crashes on BTS query. (LP: #1512200)
4
5 -- Shih-Yuan Lee (FourDollars) <sylee@canonical.com> Mon, 02 Nov 2015 13:27:45 +0800
6
1python-debianbts (1.12) unstable; urgency=medium7python-debianbts (1.12) unstable; urgency=medium
28
3 * Added HTTP_PROXY support by applying the patch from Raphael Kubo da Costa,9 * Added HTTP_PROXY support by applying the patch from Raphael Kubo da Costa,
410
=== modified file 'debian/control'
--- debian/control 2012-04-16 10:40:08 +0000
+++ debian/control 2015-11-02 06:35:16 +0000
@@ -1,8 +1,9 @@
1Source: python-debianbts1Source: python-debianbts
2Section: python2Section: python
3Priority: optional3Priority: optional
4Maintainer: Bastian Venthur <venthur@debian.org>4Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
5Build-Depends: debhelper (>= 9), python-support (>= 0.6), python5XSBC-Original-Maintainer: Bastian Venthur <venthur@debian.org>
6Build-Depends: debhelper (>= 9), python-support (>= 0.6), python, python-mock
6Standards-Version: 3.9.3.17Standards-Version: 3.9.3.1
7Vcs-Git: git://github.com/venthur/python-debianbts.git8Vcs-Git: git://github.com/venthur/python-debianbts.git
8Vcs-Browser: http://github.com/venthur/python-debianbts9Vcs-Browser: http://github.com/venthur/python-debianbts
910
=== modified file 'src/debianbts.py'
--- src/debianbts.py 2014-07-07 14:50:29 +0000
+++ src/debianbts.py 2015-11-02 06:35:16 +0000
@@ -27,17 +27,24 @@
2727
2828
29from datetime import datetime29from datetime import datetime
30import os
30import urllib31import urllib
31import urlparse32import urlparse
3233
33import SOAPpy34import SOAPpy
3435
36# Support running from Debian infrastructure
37ca_path = '/etc/ssl/ca-debian'
38if os.path.isdir(ca_path):
39 os.environ['SSL_CERT_DIR'] = ca_path
3540
36# Setup the soap server41# Setup the soap server
37# Default values42# Default values
38URL = 'http://bugs.debian.org/cgi-bin/soap.cgi'43URL = 'https://bugs.debian.org/cgi-bin/soap.cgi'
39NS = 'Debbugs/SOAP/V1'44NS = 'Debbugs/SOAP/V1'
40BTS_URL = 'http://bugs.debian.org/'45BTS_URL = 'https://bugs.debian.org/'
46# Max number of bugs to send in a single get_status request
47BATCH_SIZE = 500
4148
4249
43def _get_http_proxy():50def _get_http_proxy():
@@ -174,20 +181,28 @@
174 return val181 return val
175182
176183
177def get_status(*nr):184def get_status(*nrs):
178 """Returns a list of Bugreport objects."""185 """Returns a list of Bugreport objects."""
179 reply = server.get_status(*nr)
180 # If we called get_status with one single bug, we get a single bug,186 # If we called get_status with one single bug, we get a single bug,
181 # if we called it with a list of bugs, we get a list,187 # if we called it with a list of bugs, we get a list,
182 # No available bugreports returns an enmpy list188 # No available bugreports returns an empty list
183 bugs = []189 bugs = []
184 if not reply:190 def parse(n):
185 pass191 if not n:
186 elif type(reply[0]) == type([]):192 return []
187 for elem in reply[0]:193 elif type(reply[0]) == type([]):
188 bugs.append(_parse_status(elem))194 return [_parse_status(elem) for elem in reply[0]]
189 else:195 else:
190 bugs.append(_parse_status(reply[0]))196 return [_parse_status(reply[0])]
197 # Process the input in batches to avoid hitting resource limits on the BTS
198 for nr in nrs:
199 if isinstance(nr, list):
200 for i in range(0, len(nr), BATCH_SIZE):
201 reply = server.get_status(nr[i:i+BATCH_SIZE])
202 bugs.extend(parse(reply))
203 else:
204 reply = server.get_status(nr)
205 bugs.extend(parse(reply))
191 return bugs206 return bugs
192207
193208
194209
=== modified file 'test/test_debianbts.py'
--- test/test_debianbts.py 2014-07-07 14:50:29 +0000
+++ test/test_debianbts.py 2015-11-02 06:35:16 +0000
@@ -18,7 +18,12 @@
18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.18# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
1919
2020
21import math
21import unittest22import unittest
23try:
24 import unittest.mock as mock
25except ImportError:
26 import mock
2227
23import debianbts as bts28import debianbts as bts
2429
@@ -83,6 +88,15 @@
83 self.assertEqual(type(i["header"]), type(unicode()))88 self.assertEqual(type(i["header"]), type(unicode()))
84 self.assertTrue(i.has_key("msg_num"))89 self.assertTrue(i.has_key("msg_num"))
85 self.assertEqual(type(i["msg_num"]), type(int()))90 self.assertEqual(type(i["msg_num"]), type(int()))
91
92 def testStatusBatchesLargeBugCounts(self):
93 """get_status should perform requests in batches to reduce server load."""
94 with mock.patch.object(bts.server, 'get_status') as MockStatus:
95 MockStatus.return_value = None
96 nr = bts.BATCH_SIZE + 10.0
97 calls = int(math.ceil(nr / bts.BATCH_SIZE))
98 bts.get_status([722226] * int(nr))
99 self.assertEqual(MockStatus.call_count, calls)
86100
87 def testComparison(self):101 def testComparison(self):
88 self.b1.archived = True102 self.b1.archived = True

Subscribers

People subscribed via source and target branches

to all changes: