diff -u smart-1.2/debian/changelog smart-1.2/debian/changelog --- smart-1.2/debian/changelog +++ smart-1.2/debian/changelog @@ -1,3 +1,10 @@ +smart (1.2-5ubuntu0.2) lucid-proposed; urgency=low + + * Handle authentication errors when using pycurl, giving a meaningful + error message. (LP: #244453) + + -- Andreas Hasenack Wed, 07 Sep 2011 11:12:42 -0300 + smart (1.2-5ubuntu0.1) lucid-proposed; urgency=low * Fix for dealing with incorrect installed-size fields. (LP: #512302) only in patch2: unchanged: --- smart-1.2.orig/debian/patches/07_handle_auth_error.patch +++ smart-1.2/debian/patches/07_handle_auth_error.patch @@ -0,0 +1,63 @@ +=== modified file 'smart/fetcher.py' +--- a/smart/fetcher.py 2010-03-07 22:15:56 +0000 ++++ b/smart/fetcher.py 2010-03-07 22:23:54 +0000 +@@ -1585,6 +1585,8 @@ + multi.remove_handle(handle) + self._lock.release() + ++ http_code = handle.getinfo(pycurl.HTTP_CODE) ++ + del self._active[handle] + userhost = (url.user, url.host, url.port) + self._inactive[handle] = userhost +@@ -1598,6 +1600,9 @@ + self._queue.append(item) + self._activelimit[item.getURL().host] = handle.active + del self._inactive[handle] ++ elif http_code == 404: ++ # Use a standard translatable error message. ++ item.setFailed(_("File not found")) + else: + item.setFailed(errmsg) + +@@ -1683,6 +1688,7 @@ + handle.setopt(pycurl.MAXREDIRS, 5) + handle.setopt(pycurl.HTTPHEADER, ["Pragma:"]) + handle.setopt(pycurl.USERAGENT, "smart/" + VERSION) ++ handle.setopt(pycurl.FAILONERROR, 1) + + # check if we have a valid local file and use I-M-S + if fetcher.validate(item, localpath): + +=== modified file 'tests/fetcher.py' +--- a/tests/fetcher.py 2010-03-03 11:55:34 +0000 ++++ b/tests/fetcher.py 2010-03-07 22:23:54 +0000 +@@ -9,7 +9,7 @@ + from smart.progress import Progress + from smart.interface import Interface + from smart.fetcher import Fetcher +-from smart.const import VERSION ++from smart.const import VERSION, SUCCEEDED, FAILED + from smart import fetcher, iface + + from tests.mocker import MockerTestCase +@@ -101,6 +101,18 @@ + del os.environ["http_proxy"] + self.assertTrue("Pragma: no-cache\r\n" not in headers) + ++ def test_401_handling(self): ++ headers = [] ++ def handler(request): ++ request.send_error(401, "Authorization Required") ++ request.send_header("Content-Length", "17") ++ request.wfile.write("401 Unauthorized.") ++ self.start_server(handler) ++ self.fetcher.enqueue(URL) ++ self.fetcher.run(progress=Progress()) ++ item = self.fetcher.getItem(URL) ++ self.assertEquals(item.getStatus(), FAILED) ++ + def test_404_handling(self): + headers = [] + def handler(request): +