def process_response(self, response): """ Adds a 'get_lines' function that returns a generator that yields every line in order. """ response = _Request.process_response(self, response) response.get_lines = lambda : (value for (key, value) in sorted(response.items()) if key.startswith('Line-')) return response
def process_response(self, response): """ Indicates success if the response matches one of the valid patterns. """ response = _Request.process_response(self, response) response.success = response.get('Response') in ('Events On', 'Events Off') return response
def process_response(self, response): """ Indicates success if the response matches one of the valid patterns. """ response = _Request.process_response(self, response) response.success = response.get("Response") in ("Events On", "Events Off") return response
def process_response(self, response): """ Sets the 'ACL', 'Dynamic', 'MD5SecretExist', 'SecretExist', 'SIP-CanReinvite', 'SIP-PromiscRedir', 'SIP-UserPhone', 'SIP-VideoSupport', and 'SIP-AuthInsecure' headers' values to booleans. Sets the 'Address-Port', 'MaxCallBR', and 'RegExpire' headers' values to ints, with -1 indicating failure. """ response = _Request.process_response(self, response) for header in ( 'ACL', 'Dynamic', 'MD5SecretExist', 'SecretExist', 'SIP-CanReinvite', 'SIP-PromiscRedir', 'SIP-UserPhone', 'SIP-VideoSupport', ): response[header] = response.get(header) == 'Y' response['SIP-AuthInsecure'] = response.get('SIP-AuthInsecure') == 'yes' try: response['Address-Port'] = int(response.get('Address-Port')) except Exception: response['Address-Port'] = -1 for header in ('MaxCallBR', 'RegExpire'): try: response[header] = int(response.get(header).split()[0]) except Exception: response[header] = -1 return response
def process_response(self, response): """ Raises `ManagerAuthError` if an error is received while attempting to authenticate. """ if response.get('Response') == 'Error': raise ManagerAuthError(response.get('Message')) return _Request.process_response(self, response)
def process_response(self, response): """ Adds a 'get_lines' function that returns a generator that yields every line in order. """ response = _Request.process_response(self, response) response.get_lines = lambda: (value for (key, value) in sorted(response.items()) if key.startswith("Line-")) return response
def process_response(self, response): """ Converts the waiting-message-count into an integer. """ response = _Request.process_response(self, response) generic_transforms.to_int(response, ('Waiting',), -1) return response
def process_response(self, response): """ Converts the message-counts into integers. """ response = _Request.process_response(self, response) generic_transforms.to_int(response, ('NewMessages', 'OldMessages',), -1) return response
def process_response(self, response): """ Converts the waiting-message-count into an integer. """ response = _Request.process_response(self, response) generic_transforms.to_int(response, ('Waiting', ), -1) return response
def process_response(self, response): """ Sets the 'ACL', 'Dynamic', 'MD5SecretExist', 'SecretExist', 'SIP-CanReinvite', 'SIP-PromiscRedir', 'SIP-UserPhone', 'SIP-VideoSupport', and 'SIP-AuthInsecure' headers' values to booleans. Sets the 'Address-Port', 'MaxCallBR', and 'RegExpire' headers' values to ints, with -1 indicating failure. """ response = _Request.process_response(self, response) generic_transforms.to_bool(response, ( 'ACL', 'Dynamic', 'MD5SecretExist', 'SecretExist', 'SIP-CanReinvite', 'SIP-PromiscRedir', 'SIP-UserPhone', 'SIP-VideoSupport', ), truth_value='Y') generic_transforms.to_bool(response, ('SIP-AuthInsecure', ), truth_value='yes') generic_transforms.to_int(response, ('Address-Port', ), -1) generic_transforms.to_int(response, ('MaxCallBR', 'RegExpire'), -1, preprocess=(lambda x: x.split()[0])) return response
def process_response(self, response): """ Raises `ManagerAuthError` if an error is received while attempting to authenticate. """ if response.get("Response") == "Error": raise ManagerAuthError(response.get("Message")) return _Request.process_response(self, response)
def process_response(self, response): """ Converts the message-counts into integers. """ response = _Request.process_response(self, response) generic_transforms.to_int(response, ( 'NewMessages', 'OldMessages', ), -1) return response
def process_response(self, response): """ Adds the number of seconds elapsed since the message was prepared for transmission under the 'RTT' key or sets it to -1 in case the server didn't respond as expected. """ response = _Request.process_response(self, response) if response.get("Response") == "Pong": response["RTT"] = time.time() - self._start_time else: response["RTT"] = -1 return response
def process_response(self, response): """ Converts the waiting-message-count into an integer. """ response = _Request.process_response(self, response) messages = self.get("Waiting") if messages is not None and messages.isdigit(): self["Waiting"] = int(messages) else: self["Waiting"] = -1 return response
def process_response(self, response): """ Converts the waiting-message-count into an integer. """ response = _Request.process_response(self, response) messages = self.get('Waiting') if messages is not None and messages.isdigit(): self['Waiting'] = int(messages) else: self['Waiting'] = -1 return response
def process_response(self, response): """ Adds the number of seconds elapsed since the message was prepared for transmission under the 'RTT' key or sets it to -1 in case the server didn't respond as expected. """ response = _Request.process_response(self, response) if response.get('Response') == 'Pong': response['RTT'] = time.time() - self._start_time else: response['RTT'] = -1 return response
def process_response(self, response): """ Converts the message-counts into integers. """ response = _Request.process_response(self, response) for messages in ('NewMessages', 'OldMessages'): msgs = self.get(messages) if msgs is not None and msgs.isdigit(): self[messages] = int(msgs) else: self[messages] = -1 return response
def process_response(self, response): """ Converts the message-counts into integers. """ response = _Request.process_response(self, response) for messages in ("NewMessages", "OldMessages"): msgs = self.get(messages) if msgs is not None and msgs.isdigit(): self[messages] = int(msgs) else: self[messages] = -1 return response
def process_response(self, response): """ Sets the 'ACL', 'Dynamic', 'MD5SecretExist', 'SecretExist', 'SIP-CanReinvite', 'SIP-PromiscRedir', 'SIP-UserPhone', 'SIP-VideoSupport', and 'SIP-AuthInsecure' headers' values to booleans. Sets the 'Address-Port', 'MaxCallBR', and 'RegExpire' headers' values to ints, with -1 indicating failure. """ response = _Request.process_response(self, response) generic_transforms.to_bool(response, ( 'ACL', 'Dynamic', 'MD5SecretExist', 'SecretExist', 'SIP-CanReinvite', 'SIP-PromiscRedir', 'SIP-UserPhone', 'SIP-VideoSupport', ), truth_value='Y') generic_transforms.to_bool(response, ('SIP-AuthInsecure',), truth_value='yes') generic_transforms.to_int(response, ('Address-Port',), -1) generic_transforms.to_int(response, ('MaxCallBR', 'RegExpire'), -1, preprocess=(lambda x:x.split()[0])) return response
def process_response(self, response): """ Sets the 'ACL', 'Dynamic', 'MD5SecretExist', 'SecretExist', 'SIP-CanReinvite', 'SIP-PromiscRedir', 'SIP-UserPhone', 'SIP-VideoSupport', and 'SIP-AuthInsecure' headers' values to booleans. Sets the 'Address-Port', 'MaxCallBR', and 'RegExpire' headers' values to ints, with -1 indicating failure. """ response = _Request.process_response(self, response) for header in ( "ACL", "Dynamic", "MD5SecretExist", "SecretExist", "SIP-CanReinvite", "SIP-PromiscRedir", "SIP-UserPhone", "SIP-VideoSupport", ): response[header] = response.get(header) == "Y" response["SIP-AuthInsecure"] = response.get("SIP-AuthInsecure") == "yes" try: response["Address-Port"] = int(response.get("Address-Port")) except Exception: response["Address-Port"] = -1 for header in ("MaxCallBR", "RegExpire"): try: response[header] = int(response.get(header).split()[0]) except Exception: response[header] = -1 return response