def __init__(self, username, password, debug = False): self.debug = debug if debug: logging.getLogger("suds.server").setLevel(logging.DEBUG) logging.getLogger("suds.client").setLevel(logging.DEBUG) logging.getLogger("suds.transport").setLevel(logging.DEBUG) else: logging.getLogger('suds.client').setLevel(logging.CRITICAL) # hide soap faults try: self.client = suds.client.Client(url = self.url, username = username, password = password) except suds.transport.TransportError as (err): if err.httpcode == 401: print "Error: Invalid username or password" else: print "Error: Unknown error: %s" % str(err) errorhandler.exit(3)
def call(self, func, args): if (self.debug): print "# Calling %s %s" % (func, args) try: method = getattr(self.client.service, func) result = method(*args) if self.requestId is None: if "requestId" in result: self.requestId = result["requestId"] else: self.requestId = "(no info)" return result except suds.WebFault as (err): print "Error: %s" % str(err) errorhandler.exit(2) except suds.transport.TransportError as (err): if err.httpcode == 401: print "Error: Invalid username or password" else: print "Error: Unknown error: %s" % str(err) errorhandler.exit(3)