Exemple #1
0
 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
Exemple #2
0
 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
Exemple #3
0
 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
Exemple #4
0
 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
Exemple #5
0
 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
Exemple #6
0
 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)
Exemple #7
0
 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
Exemple #8
0
 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
Exemple #9
0
 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
Exemple #10
0
 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
Exemple #11
0
 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
Exemple #12
0
    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
Exemple #13
0
 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)
Exemple #14
0
 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
Exemple #15
0
 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
Exemple #16
0
 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
Exemple #17
0
 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
Exemple #18
0
 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
Exemple #19
0
 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
Exemple #20
0
 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
Exemple #21
0
 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
Exemple #22
0
    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