コード例 #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
コード例 #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
コード例 #3
0
ファイル: core.py プロジェクト: sandeepraju/pystrix
 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
コード例 #4
0
ファイル: core.py プロジェクト: axonxorz/pystrix
 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
コード例 #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
コード例 #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)
コード例 #7
0
ファイル: core.py プロジェクト: sandeepraju/pystrix
 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
コード例 #8
0
ファイル: core.py プロジェクト: nhtdata/pystrix
 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
コード例 #9
0
ファイル: core.py プロジェクト: nhtdata/pystrix
 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
コード例 #10
0
ファイル: core.py プロジェクト: nhtdata/pystrix
 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
コード例 #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
コード例 #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
コード例 #13
0
ファイル: core.py プロジェクト: sandeepraju/pystrix
 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)
コード例 #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
コード例 #15
0
ファイル: core.py プロジェクト: sandeepraju/pystrix
 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
コード例 #16
0
ファイル: core.py プロジェクト: sandeepraju/pystrix
 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
コード例 #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
コード例 #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
コード例 #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
コード例 #20
0
ファイル: core.py プロジェクト: sandeepraju/pystrix
 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
コード例 #21
0
ファイル: core.py プロジェクト: nhtdata/pystrix
 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
コード例 #22
0
ファイル: core.py プロジェクト: sandeepraju/pystrix
    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