From d7d1e7f4aa7ed0e989d6d16f47537b6416debe2b Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Sat, 28 Apr 2018 16:17:28 +0300 Subject: Support overriding GSX_URL --- gsxws/core.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gsxws') diff --git a/gsxws/core.py b/gsxws/core.py index b9d6f62..87f767b 100644 --- a/gsxws/core.py +++ b/gsxws/core.py @@ -98,7 +98,7 @@ ENVIRONMENTS = ( ) GSX_HOSTS = {'pr': '', 'it': 'it', 'ut': 'ut'} -GSX_URL = "https://gsxapi{env}.apple.com/gsx-ws/services/{region}/asp" +GSX_URL = os.getenv('GSX_URL', "https://gsxapi{env}.apple.com/gsx-ws/services/{region}/asp") def validate(value, what=None): @@ -198,6 +198,10 @@ class GsxError(Exception): except IndexError: return 'XXX' + @property + def message(self): + return self.messages[0] + @property def errors(self): return dict(list(zip(self.codes, self.messages))) @@ -367,7 +371,7 @@ class GsxRequest(object): logging.debug("Response: %s %s %s" % (res.status_code, res.reason, xml)) if res.status_code > 200: - raise GsxError(xml=xml, url=self._url, status=res.status_code) + raise GsxError(xml=xml, url=self._url, status=res.status_code, message=res.reason) if raw is True: return ET.fromstring(self.xml_response) -- cgit v1.2.3