[Reportbug-commits] [reportbug] 10/32: port reportbug.checkbuildd to HTMLParser and py3k
Sandro Tosi
morph at moszumanska.debian.org
Thu Dec 1 01:36:51 UTC 2016
This is an automated email from the git hooks/post-receive script.
morph pushed a commit to branch master
in repository reportbug.
commit 328440f6a6c86337e2eba862c30cc5e251d993b8
Author: Sandro Tosi <morph at debian.org>
Date: Fri Nov 25 16:29:07 2016 -0500
port reportbug.checkbuildd to HTMLParser and py3k
---
reportbug/checkbuildd.py | 29 ++++++++++++++---------------
test/test_checkbuildd.py | 8 ++++----
2 files changed, 18 insertions(+), 19 deletions(-)
diff --git a/reportbug/checkbuildd.py b/reportbug/checkbuildd.py
index f9c1720..18110ef 100644
--- a/reportbug/checkbuildd.py
+++ b/reportbug/checkbuildd.py
@@ -21,11 +21,10 @@
# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
# SOFTWARE.
-import sgmllib
-import commands
+from html.parser import HTMLParser
-import utils
-from urlutils import open_url
+from . import utils
+from .urlutils import open_url
from reportbug.exceptions import (
NoNetwork,
)
@@ -34,9 +33,9 @@ BUILDD_URL = 'https://buildd.debian.org/build.php?arch=%s&pkg=%s'
# Check for successful in a 'td' block
-class BuilddParser(sgmllib.SGMLParser):
+class BuilddParser(HTMLParser):
def __init__(self):
- sgmllib.SGMLParser.__init__(self)
+ HTMLParser.__init__(self)
self.versions = {}
self.savedata = None
self.found_succeeded = False
@@ -59,13 +58,15 @@ class BuilddParser(sgmllib.SGMLParser):
data = ' '.join(data.split())
return data
- def start_td(self, attrs):
- self.save_bgn()
+ def handle_starttag(self, tag, attrs):
+ if tag == 'td':
+ self.save_bgn()
- def end_td(self):
- data = self.save_end()
- if data and 'successful' in data.lower():
- self.found_succeeded = True
+ def handle_endtag(self, tag):
+ if tag == 'td':
+ data = self.save_end()
+ if data and 'successful' in data.lower():
+ self.found_succeeded = True
def check_built(src_package, timeout, arch=None, http_proxy=None):
@@ -82,8 +83,6 @@ def check_built(src_package, timeout, arch=None, http_proxy=None):
return False
parser = BuilddParser()
- parser.feed(page.read())
- parser.close()
- page.close()
+ parser.feed(page)
return parser.found_succeeded
diff --git a/test/test_checkbuildd.py b/test/test_checkbuildd.py
index 994af54..002e30e 100644
--- a/test/test_checkbuildd.py
+++ b/test/test_checkbuildd.py
@@ -1,15 +1,15 @@
-import unittest2
+import unittest
from reportbug import checkbuildd
from nose.plugins.attrib import attr
-class TestCheckbuildd(unittest2.TestCase):
+class TestCheckbuildd(unittest.TestCase):
@attr('network') # marking the test as using network
def test_check_built(self):
built = checkbuildd.check_built('gkrellm', 60)
self.assertTrue(built)
- # timeout too small, will trigger exception and so a 'False' result
- built = checkbuildd.check_built('gkrellm', 0)
+ # check for a non-existing package, that triggers a failure
+ built = checkbuildd.check_built('non-existing-pkg', 60)
self.assertFalse(built)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reportbug/reportbug.git
More information about the Reportbug-commits
mailing list