From dc707538110ba368c05d2eb560bd1f20fdc3574b Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Thu, 14 Mar 2013 18:17:33 +0200 Subject: Through GsxError on Repair.mark_complete() --- README.md | 2 +- gsxws.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index e6ae8bc..3db385b 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Currently it supports most of them. Installation: - pip install -e git+git://github.com/filipp/py-gsxws.git#egg=gsxws + pip install -U -e git+git://github.com/filipp/py-gsxws.git#egg=gsxws It goes a little something like this: diff --git a/gsxws.py b/gsxws.py index 1eb404d..0685c62 100755 --- a/gsxws.py +++ b/gsxws.py @@ -326,10 +326,14 @@ class GsxResponse(dict): return nodedict class GsxError(Exception): - def __init__(self, message, code=None): - self.code = code - self.message = message - self.data = (self.code, self.message) + def __init__(self, message=None, code=None, fault=None): + if isinstance(fault, suds.WebFault): + self.code = fault.fault.faultcode + self.message=fault.fault.faultstring + else: + self.code = code + self.message = message + self.data = (self.code, self.message) def __getitem__(self, idx): return self.data[idx] @@ -602,7 +606,10 @@ class Repair(GsxObject): dt.repairConfirmationNumbers = [self.data['dispatchId']] result = CLIENT.service.MarkRepairComplete(dt) - return result.repairConfirmationNumbers + try: + return result.repairConfirmationNumbers + except suds.WebFault, e: + raise GsxError(fault=e) def delete(self): """ -- cgit v1.2.3