def getToonList(accountName): """ Retrieve a list of toons owned by the given account. accountName is the account name string as stored on the OTP server. Returns a list of (DOID,name) tuples. """ assert self.requestQueue.empty() assert self.resultQueue.empty() if not isinstance(accountName, str): raise RPCException("Argument accountName was not a string.") c = SOAPpy.GetSOAPContext() self.requestQueue.put(GetToonIdListRequest(self.resultQueue, \ c.connection.getpeername()[0], \ accountName)) idList = self.resultQueue.get() if isinstance(idList, TimeoutException): raise RPCException("Request timed out.") resultList = [] for doid in idList: if doid > 0: toonname = self.getToonName(doid) resultList.append((doid, toonname)) return resultList
def giveToonBeansCS(toonID, beanAmount): """ Only for Customer Service requests. Give jellybeans to the toon specified. toonID is the DOID of the recipient toon. beanAmount is the number of beans to give (0 < beanAmount <= 100). Returns None on success, faults on failure. """ assert self.requestQueue.empty() assert self.resultQueue.empty() if not isinstance(toonID, int): raise RPCException, "Argument toonID was not an int." if not isinstance(beanAmount, int): raise RPCException, "Argument beanAmount was not an int." if toonID < 1: raise RPCException, "Argument toonID was non-positive." if beanAmount > 100: raise RPCException, "Attempted to give a toon more than 100 jellybeans at once" if beanAmount < 1: raise RPCException, "Attempted to give a toon a non-positive jellybean amount" c = SOAPpy.GetSOAPContext() self.requestQueue.put(GiveToonBeansCSRequest(self.resultQueue, \ c.connection.getpeername()[0], \ toonID, \ beanAmount)) result = self.resultQueue.get() return
def getToonDNA(toonID): """ Retrieve the DNA for a given toon. toonID is the toon's DOID """ assert self.requestQueue.empty() assert self.resultQueue.empty() if not isinstance(toonID, int): raise RPCException("Argument toonID was not an int.") if toonID < 1: raise RPCException("Argument toonID was non-positive.") c = SOAPpy.GetSOAPContext() self.requestQueue.put(GetToonDNARequest(self.resultQueue, \ c.connection.getpeername()[0], \ toonID)) dna = self.resultQueue.get() if isinstance(dna, TimeoutException): raise RPCException("Request timed out.") return dna
def getToonPicId(toonID): """ Retrieve the picture ID for a given toon. toonID is the toon's DOID """ assert self.requestQueue.empty() assert self.resultQueue.empty() if not isinstance(toonID, int): raise RPCException, "Argument toonID was not an int." if toonID < 1: raise RPCException, "Argument toonID was non-positive." c = SOAPpy.GetSOAPContext() self.requestQueue.put(GetToonPicIdRequest(self.resultQueue, \ c.connection.getpeername()[0], \ toonID)) picid = self.resultQueue.get() if isinstance(picid, TimeoutException): raise RPCException, "Request timed out." return picid
def soap_set(self, appliance): c = SOAPpy.GetSOAPContext() ipaddr = c.httpheaders.get('X-Forwarded-For', c.connection.getpeername()[0]) return self.next_set(ipaddr, appliance)