Example #1
0
    def process(self):
        """
        Translates the 'MaxMessageCount', 'MaxMessageLength', 'NewMessageCount', 'OldMessageCount',
        and 'SayDurationMinimum' values into ints, setting them to -1 on error.

        Translates the 'VolumeGain' value into a float, setting it to None on error.
        
        Translates the 'AttachMessage', 'CallOperator', 'CanReview', 'DeleteMessage', 'SayCID', and
        'SayEnvelope' values into booleans.
        """
        (headers, data) = _Event.process(self)

        generic_transforms.to_bool(headers, (
            'AttachMessage',
            'CallOperator',
            'CanReview',
            'DeleteMessage',
            'SayCID',
            'SayEnvelope',
        ),
                                   truth_value='Yes')
        header_list = [
            'MaxMessageCount', 'MaxMessageLength', 'NewMessageCount',
            'SayDurationMinimum'
        ]
        if 'OldMessageCount' in headers:
            header_list.append('OldMessageCount')
        generic_transforms.to_int(headers, header_list, -1)
        generic_transforms.to_float(headers, ('VolumeGain', ), None)

        return (headers, data)
Example #2
0
 def process(self):
     """
     Translates the 'Port' header's value into an int, setting it to `None` if coercion
     fails, and leaving it absent if it wasn't present in the original response.
     
     Translates the 'Dynamic', 'Natsupport', 'VideoSupport', 'ACL', and 'RealtimeDevice' headers'
     values into bools.
     
     Translates 'Status' into the number of milliseconds since the peer was last seen or -2 if
     unmonitored. -1 if parsing failed.
     """
     (headers, data) = _Event.process(self)
     
     try:
         if headers['Status'] == 'Unmonitored':
             headers['Status'] = -2
         else:
             headers['Status'] = int(re.match(r'OK \((\d+) ms\)', headers['Status']).group(1))
     except Exception:
         headers['Status'] = -1
         
     if 'IPport' in headers:
         generic_transforms.to_int(headers, ('IPPort',), None)
         
     generic_transforms.to_bool(headers, ('Dynamic', 'Natsupport', 'VideoSupport', 'ACL', 'RealtimeDevice'), truth_value='yes')
     
     return (headers, data)
Example #3
0
 def process(self):
     """
     'Restart' is set to a bool.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_bool(headers, ('Restart', ), truth_value='True')
     return (headers, data)
Example #4
0
 def process(self):
     """
     'Paused' is set to a bool.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_bool(headers, ('Paused',), truth_value='1')
     return (headers, data)
Example #5
0
 def process(self):
     """
     'Paused' is set to a bool.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_bool(headers, ('Paused', ), truth_value='1')
     return (headers, data)
Example #6
0
    def process(self):
        """
        Translates the 'CumulativeLoss', 'SentOctets', 'SentPackets', 'SentRTP', and
        'TheirLastSR' values into ints, setting them to -1 on error.

        Translates the 'DLSR', 'FractionLost', 'IAJitter', and 'SentNTP' values into floats, setting
        them to -1 on error.

        Splits 'To' into a tuple of IP:str and port:int, or sets it to `None` if the format is
        unknown.
        """
        (headers, data) = _Event.process(self)
        
        to = headers.get('To')
        if to and ':' in to:
            headers['To'] = tuple(to.rsplit(':', 1))
        else:
            headers['To'] = None
            
        generic_transforms.to_bool(headers, ('Result',), truth_value='Success')
        generic_transforms.to_int(headers, ('CumulativeLoss', 'SentOctets', 'SentPackets', 'SentRTP', 'TheirLastSR',), -1)
        headers['DLSR'] = (headers.get('DSLR') or '').split(' ', 1)[0]
        generic_transforms.to_float(headers, ('DLSR', 'FractionLost', 'IAJitter', 'SentNTP',), -1)
            
        return (headers, data)
Example #7
0
    def process(self):
        """
        Translates the 'Port' header's value into an int, setting it to `None` if coercion
        fails, and leaving it absent if it wasn't present in the original response.
        
        Translates the 'Dynamic', 'Natsupport', 'VideoSupport', 'ACL', and 'RealtimeDevice' headers'
        values into bools.
        
        Translates 'Status' into the number of milliseconds since the peer was last seen or -2 if
        unmonitored. -1 if parsing failed.
        """
        (headers, data) = _Event.process(self)

        try:
            if headers['Status'] == 'Unmonitored':
                headers['Status'] = -2
            else:
                headers['Status'] = int(
                    re.match(r'OK \((\d+) ms\)', headers['Status']).group(1))
        except Exception:
            headers['Status'] = -1

        if 'IPport' in headers:
            generic_transforms.to_int(headers, ('IPPort', ), None)

        generic_transforms.to_bool(
            headers,
            ('Dynamic', 'Natsupport', 'VideoSupport', 'ACL', 'RealtimeDevice'),
            truth_value='yes')

        return (headers, data)
Example #8
0
 def process(self):
     """
     'Restart' is set to a bool.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_bool(headers, ('Restart',), truth_value='True')
     return (headers, data)
Example #9
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
Example #10
0
    def process(self):
        """
        Translates the 'Admin' and 'MarkedUser' headers' values into bools.
        
        Translates the 'Talking' header's value into a bool, or `None` if not monitored.
        
        Translates the 'UserNumber' header's value into an int, or -1 on failure.
        """
        (headers, data) = _Event.process(self)

        talking = headers.get('Talking')
        if talking == 'Yes':
            headers['Talking'] = True
        elif talking == 'No':
            headers['Talking'] = False
        else:
            headers['Talking'] = None

        generic_transforms.to_bool(headers, (
            'Admin',
            'MarkedUser',
        ),
                                   truth_value='Yes')
        generic_transforms.to_int(headers, ('UserNumber', ), -1)

        return (headers, data)
Example #11
0
 def process(self):
     """
     Translates the 'Admin' and 'MarkedUser' headers' values into bools.
     """
     (headers, data) = _Event.process(self)
     
     generic_transforms.to_bool(headers, ('Admin', 'MarkedUser',), truth_value='Yes')
         
     return (headers, data)
Example #12
0
 def process(self):
     """
     Translates the 'TalkingStatus' header's value into a bool.
     """
     (headers, data) = _Event.process(self)
     
     generic_transforms.to_bool(headers, ('TalkingStatus',), truth_value='on')
     
     return (headers, data)
Example #13
0
    def process(self):
        """
        Translates the 'Status' header's value into a bool.
        """
        (headers, data) = _Event.process(self)

        generic_transforms.to_bool(headers, ('Status', ), truth_value='on')

        return (headers, data)
Example #14
0
 def process(self):
     """
     Translates 'Begin' and 'End' into booleans, and adds a 'Received':bool header.
     """
     (headers, data) = _Event.process(self)
     
     headers['Received'] = headers.get('Direction') == 'Received'
     generic_transforms.to_bool(headers, ('Begin', 'End',), truth_value='Yes')
     
     return (headers, data)
Example #15
0
 def process(self):
     """
     Translates the 'CallsTaken', 'LastCall', 'Penalty', and 'Status' headers' values into ints,
     setting them to -1 on error.
     
     'Paused' is set to a bool.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_bool(headers, ('Paused',), truth_value='1')
     generic_transforms.to_int(headers, ('CallsTaken', 'LastCall', 'Penalty', 'Status',), -1)
     return (headers, data)
Example #16
0
    def process(self):
        """
        Translates the 'Parties' header's value into an int, or -1 on failure.
        
        Translates the 'Locked' header's value into a bool.
        """
        (headers, data) = _Event.process(self)

        generic_transforms.to_bool(headers, ('Locked', ), truth_value='Yes')
        generic_transforms.to_int(headers, ('Parties', ), -1)

        return (headers, data)
Example #17
0
 def process(self):
     """
     Translates the 'Marked' and 'Parties' headers' values into ints, or -1 on failure.
     
     Translates the 'Locked' header's value into a bool.
     """
     (headers, data) = _Event.process(self)
     
     generic_transforms.to_bool(headers, ('Locked',), truth_value='Yes')
     generic_transforms.to_int(headers, ('Marked', 'Parties',), -1)
     
     return (headers, data)
Example #18
0
 def process(self):
     """
     Translates the 'Result' header's value into a bool.
     
     Translates the 'ResultCode' header's value into an int, setting it to `-1` if coercion
     fails.
     """
     (headers, data) = _Event.process(self)
     
     generic_transforms.to_bool(headers, ('Result',), truth_value='Success')
     generic_transforms.to_int(headers, ('ResultCode',), -1)
     
     return (headers, data)
    def process(self):
        """
        Translates the 'Admin' and 'MarkedUser' headers' values into bools.
        """
        (headers, data) = _Event.process(self)

        generic_transforms.to_bool(headers, (
            'Admin',
            'MarkedUser',
        ),
                                   truth_value='Yes')

        return (headers, data)
Example #20
0
 def process(self):
     """
     Translates the 'DND' header's value into a bool.
     
     Translates the 'DAHDIChannel' and 'SignallingCode' headers' values into ints, or -1 on
     failure.
     """
     (headers, data) = _Event.process(self)
     
     generic_transforms.to_bool(headers, ('DND',), truth_value='Enabled')
     generic_transforms.to_int(headers, ('DAHDIChannel', 'SignallingCode',), -1)
             
     return (headers, data)
Example #21
0
    def process(self):
        """
        Translates 'Begin' and 'End' into booleans, and adds a 'Received':bool header.
        """
        (headers, data) = _Event.process(self)

        headers['Received'] = headers.get('Direction') == 'Received'
        generic_transforms.to_bool(headers, (
            'Begin',
            'End',
        ),
                                   truth_value='Yes')

        return (headers, data)
Example #22
0
    def process(self):
        """
        Translates the 'Result' header's value into a bool.
        
        Translates the 'ResultCode' header's value into an int, setting it to `-1` if coercion
        fails.
        """
        (headers, data) = _Event.process(self)

        generic_transforms.to_bool(headers, ('Result', ),
                                   truth_value='Success')
        generic_transforms.to_int(headers, ('ResultCode', ), -1)

        return (headers, data)
Example #23
0
 def process(self):
     """
     Translates the 'CallsTaken', 'LastCall', 'Penalty', and 'Status' headers' values into ints,
     setting them to -1 on error.
     
     'Paused' is set to a bool.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_bool(headers, ('Paused', ), truth_value='1')
     generic_transforms.to_int(headers, (
         'CallsTaken',
         'LastCall',
         'Penalty',
         'Status',
     ), -1)
     return (headers, data)
Example #24
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
Example #25
0
    def process(self):
        """
        Translates the 'MaxMessageCount', 'MaxMessageLength', 'NewMessageCount', 'OldMessageCount',
        and 'SayDurationMinimum' values into ints, setting them to -1 on error.

        Translates the 'VolumeGain' value into a float, setting it to None on error.
        
        Translates the 'AttachMessage', 'CallOperator', 'CanReview', 'DeleteMessage', 'SayCID', and
        'SayEnvelope' values into booleans.
        """
        (headers, data) = _Event.process(self)
        
        generic_transforms.to_bool(headers, ('AttachMessage', 'CallOperator', 'CanReview', 'DeleteMessage', 'SayCID', 'SayEnvelope',), truth_value='Yes')
        header_list = ['MaxMessageCount', 'MaxMessageLength', 'NewMessageCount', 'SayDurationMinimum']
        if 'OldMessageCount' in headers:
            header_list.append('OldMessageCount')
        generic_transforms.to_int(headers, header_list, -1)
        generic_transforms.to_float(headers, ('VolumeGain',), None)
        
        return (headers, data)
Example #26
0
 def process(self):
     """
     Translates the 'Admin' and 'MarkedUser' headers' values into bools.
     
     Translates the 'Talking' header's value into a bool, or `None` if not monitored.
     
     Translates the 'UserNumber' header's value into an int, or -1 on failure.
     """
     (headers, data) = _Event.process(self)
     
     talking = headers.get('Talking')
     if talking == 'Yes':
         headers['Talking'] = True
     elif talking == 'No':
         headers['Talking'] = False
     else:
         headers['Talking'] = None
     
     generic_transforms.to_bool(headers, ('Admin', 'MarkedUser',), truth_value='Yes')
     generic_transforms.to_int(headers, ('UserNumber',), -1)
         
     return (headers, data)
Example #27
0
    def process(self):
        """
        Translates the 'CumulativeLoss', 'SentOctets', 'SentPackets', 'SentRTP', and
        'TheirLastSR' values into ints, setting them to -1 on error.

        Translates the 'DLSR', 'FractionLost', 'IAJitter', and 'SentNTP' values into floats, setting
        them to -1 on error.

        Splits 'To' into a tuple of IP:str and port:int, or sets it to `None` if the format is
        unknown.
        """
        (headers, data) = _Event.process(self)

        to = headers.get('To')
        if to and ':' in to:
            headers['To'] = tuple(to.rsplit(':', 1))
        else:
            headers['To'] = None

        generic_transforms.to_bool(headers, ('Result', ),
                                   truth_value='Success')
        generic_transforms.to_int(headers, (
            'CumulativeLoss',
            'SentOctets',
            'SentPackets',
            'SentRTP',
            'TheirLastSR',
        ), -1)
        headers['DLSR'] = (headers.get('DSLR') or '').split(' ', 1)[0]
        generic_transforms.to_float(headers, (
            'DLSR',
            'FractionLost',
            'IAJitter',
            'SentNTP',
        ), -1)

        return (headers, data)