summaryrefslogtreecommitdiff
path: root/swiftclient/exceptions.py
Commit message (Collapse)AuthorAgeFilesLines
* Remove sixStephen Finucane2022-03-211-1/+1
| | | | | | | This mostly affects tests. Nothing too complicated Signed-off-by: Stephen Finucane <stephenfin@redhat.com> Change-Id: Iabc78f651e1d48db35638280722f8019798eccd6
* Include transaction ID in ClientException.__str__Tim Burke2020-09-091-1/+11
| | | | | | | | | | It's fairly annoying getting a traceback in swift's probe tests then only having a URL and status code to go searching for in logs. Leave the shell.py output untouched, though, since we output the transaction ID on a new line anyway. Change-Id: Idb849848ec08b6c04812b088467c9a687c2a7e27
* Include response headers in ClientExceptionsTim Burke2016-03-031-1/+14
| | | | | | | | | | | Now, client applications can get to things like transaction IDs for failures without needing to turn on all of logging. While we're at it, add a from_response factory method for ClientException. Co-Authored-By: Alexander Corwin <ancorwin@gmail.com> Change-Id: Ib46d5f8fc7f36f651f5908bb9d900316fdaebce3
* make ClientException.http_status default to None rather than 0Zack M. Davis2015-09-041-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The extant default of zero is a bit counterintuitive; insufficiently-careful programmers using swiftclient in their application might, without carefully reading the source or documentation, write buggy code based on the assumption that the `http_status` attribute is absent or defaults to None if ClientException is raised for reasons other than to indicate an unsuccessful HTTP request. (However improbable this scenario may seem, the present author can sadly attest to it having actually happened at least once.) Just changing the default would break some tests on Python 3, due to the `500 <= err.http_status <= 599` comparison in Connection's _retry method (NoneType and int are not orderable in the Python 3.x series); thus, the case where http_status is None is explicitly folded into a code branch that logs and reraises (whereas previously it would have fallen through to an `else` branch where it would be logged and reraised just the same). While we're here, we might as well make ClientException's __init__ use super() (although admittedly the kinds of multiple-inheritance scenarios in which `super` truly shines seem unlikely to occur here). Change-Id: I8c02bfb4a0ef059e781be5e08fcde13fb1be5b88
* Use skipTest from testtools instead of inherited ExceptionChristian Schwede2014-10-081-4/+0
| | | | | | | | | | SkipTest is raised if there is no func_test section in the Swift test config file. However, the currently raised Exception will result in a failed test, not in a test marked as skipped. Since we already use testtools we can use the included skipTest easily. Change-Id: I1bbb1f9dbe31fb0698d774550708d1196b266625
* Add functional tests for python-swiftclientChristian Schwede2014-05-051-0/+4
| | | | | | | | | Coverage for swiftclient.client is 71% with these tests. Unit tests have been moved into another subdirectory to separate them from functional tests. Change-Id: Ib8c4d78f7169cee893f82906f6388a5b06c45602
* Remove validate_headersChmouel Boudjnah2014-04-171-4/+0
| | | | | | It wasn't used anymore since moved up to requests (and it fails in py3). Change-Id: Ic8a80ae09ca6445696a9cf34ffb503c5ff51bc79
* Move multi-threading code to a library.Darrell Bishop2013-07-281-0/+72
This patch extracts the multi-threading code from bin/swift into swiftclient/multithreading and adds tests. In particular, this new way of doing it (with context managers) will prevent non-daemonic threads from wedging the process when unexpected exceptions happen. I enabled reporting of which lines, specifically, are not covered by unit tests (added -m option to "coverage report" in .unittests). This patch includes a drive-by fix for uploading a segmented file with --use-slo when that object already exists. A key of "name" was used instead of "path", raising KeyError. There's also another drive-by fix for uploading segmented objects with --use-slo. Commit 874e0e4427b80e1b15b74a1557b73ba9d61443ca regressed this by removing the capturing of thread-worker results in QueueFunctionThread.run(). This patch restores that functionality and the feature (uploading SLO objects). Change-Id: I0b4f677e4a734e83d1a25088d9a74f7d46384e53