diff options
author | Filipp Lepalaan <f@230.to> | 2013-08-05 14:27:16 +0300 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-08-05 14:27:16 +0300 |
commit | 89e1c6ab62d1d49582b99fc031289b09da4583f6 (patch) | |
tree | 3d8c70fde2cfd2cc4e3b534f83da758e0d2ef5e2 | |
parent | 70fcbd4e3227a23c7525f02432aaaa05f445dbf5 (diff) | |
download | py-gsxws-89e1c6ab62d1d49582b99fc031289b09da4583f6.tar.gz py-gsxws-89e1c6ab62d1d49582b99fc031289b09da4583f6.tar.bz2 py-gsxws-89e1c6ab62d1d49582b99fc031289b09da4583f6.zip |
Fixed exceptions, added timeout
-rw-r--r-- | gsxws/core.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gsxws/core.py b/gsxws/core.py index 93dddb7..15a5c62 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -124,20 +124,17 @@ def get_format(locale=GSX_LOCALE): class GsxError(Exception): def __init__(self, message=None, xml=None, url=None): - global GSX_ENV if message is not None: - raise ValueError(message) + self.message = message if xml is not None: logging.debug(url) logging.debug(xml) el = ET.fromstring(xml) self.code = el.findtext("*//faultcode") + self.message = el.findtext("*//faultstring") - if self.code is None: - raise ValueError("An unexpected error occured") - - self.message = el.findtext("*//faultstring") + super(Exception, self).__init__(self.message) def __unicode__(self): return self.message @@ -226,7 +223,7 @@ class GsxRequest(object): logging.debug(self._url) logging.debug(xmldata) - ws = httplib.HTTPSConnection(parsed.netloc) + ws = httplib.HTTPSConnection(parsed.netloc, timeout=10) ws.putrequest("POST", parsed.path) ws.putheader("User-Agent", "py-gsxws 0.9") ws.putheader("Content-type", 'text/xml; charset="UTF-8"') |