Esempio n. 1
0
 def process(self):
     """
     Translates the 'Seconds' header's value into an int, setting it to -1 on error.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Seconds',), -1)
     return (headers, data)
Esempio n. 2
0
 def process(self):
     """
     Translates the 'Items' header's value into an int, or -1 on failure.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Items',), -1)
     return (headers, data)
Esempio n. 3
0
 def process(self):
     """
     Translates the 'Cause' header's value into an int, setting it to `None` if coercion fails.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Cause', ), None)
     return (headers, data)
Esempio n. 4
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
Esempio n. 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)

        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
Esempio n. 6
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)
Esempio n. 7
0
 def process(self):
     """
     Translates the 'Items' header's value into an int, or -1 on failure.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Items', ), -1)
     return (headers, data)
Esempio n. 8
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)
Esempio n. 9
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)
Esempio n. 10
0
 def process(self):
     """
     Translates the 'Seconds' header's value into an int, setting it to -1 on error.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Seconds', ), -1)
     return (headers, data)
Esempio n. 11
0
 def process(self):
     """
     Translates the 'Position' and 'Wait' headers' values into ints, setting them to -1 on error.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Position', 'Wait',), -1)
     return (headers, data)
Esempio n. 12
0
    def process(self):
        """
        Translates the 'HighestSequence', 'LastSR', 'PacketsLost', 'ReceptionReports,
        and 'SequenceNumbercycles' 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 'From' into a tuple of IP:str and port:int, or sets it to `None` if the format is
        unknown.
        """
        (headers, data) = _Event.process(self)

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

        generic_transforms.to_int(headers, (
            'HighestSequence',
            'LastSR',
            'PacketsLost',
            'ReceptionReports',
            'SequenceNumberCycles',
        ), -1)
        headers['DLSR'] = (headers.get('DSLR') or '').split(' ', 1)[0]
        generic_transforms.to_float(headers, (
            'DLSR',
            'FractionLost',
            'IAJitter',
        ), -1)

        return (headers, data)
Esempio n. 13
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)
Esempio n. 14
0
 def process(self):
     """
     Translates the 'Cause' header's value into an int, setting it to `None` if coercion fails.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Cause',), None)
     return (headers, data)
Esempio n. 15
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
Esempio n. 16
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)
Esempio n. 17
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
Esempio n. 18
0
 def process(self):
     """
     Translates the 'DomainPort', 'Port', 'Refresh', and 'RegistrationTime' values into ints,
     setting them to -1 on error.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('DomainPort', 'Port', 'Refresh', 'RegistrationTime',), -1)
     return (headers, data)
Esempio n. 19
0
 def process(self):
     """
     Sets the 'Reason' values to an int, one of the `ORIGINATE_RESULT` constants, with -1
     indicating failure.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Reason', ), -1)
     return (headers, data)
Esempio n. 20
0
 def process(self):
     """
     Sets the 'Reason' values to an int, one of the `ORIGINATE_RESULT` constants, with -1
     indicating failure.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Reason',), -1)
     return (headers, data)
Esempio n. 21
0
 def process(self):
     """
     Translates the 'Timeout' 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.
     """
     (headers, data) = _Event.process(self)
     if 'Timeout' in headers:
         generic_transforms.to_int(headers, ('Timeout', ), None)
     return (headers, data)
Esempio n. 22
0
 def process(self):
     """
     Translates the 'Timeout' 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.
     """
     (headers, data) = _Event.process(self)
     if 'Timeout' in headers:
         generic_transforms.to_int(headers, ('Timeout',), None)
     return (headers, data)
Esempio n. 23
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
Esempio n. 24
0
 def process(self):
     """
     Translates the 'Position' and 'Wait' headers' values into ints, setting them to -1 on error.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, (
         'Position',
         'Wait',
     ), -1)
     return (headers, data)
Esempio n. 25
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)
Esempio n. 26
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)
Esempio n. 27
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)
Esempio n. 28
0
 def process(self):
     """
     Translates the 'Abandoned', 'Calls', 'Completed', 'Holdtime', and 'Max' headers' values into
     ints, setting them to -1 on error.
     
     Translates the 'ServiceLevel', 'ServiceLevelPerf', and 'Weight' values into
     floats, setting them to -1 on error.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, ('Abandoned', 'Calls', 'Completed', 'Holdtime', 'Max',), -1)
     generic_transforms.to_float(headers, ('ServiceLevel', 'ServiceLevelPref', 'Weight',), -1)
     return (headers, data)
Esempio n. 29
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)
Esempio n. 30
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)
Esempio n. 31
0
 def process(self):
     """
     Translates the 'DomainPort', 'Port', 'Refresh', and 'RegistrationTime' values into ints,
     setting them to -1 on error.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, (
         'DomainPort',
         'Port',
         'Refresh',
         'RegistrationTime',
     ), -1)
     return (headers, data)
Esempio n. 32
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)
Esempio n. 33
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)
Esempio n. 34
0
    def process(self):
        """
        Translates the 'ChannelState' header's value into an int, setting it to `None` if coercion
        fails.
        
        Replaces the 'Duration' header's value with the number of seconds, as an int, or -1 if
        conversion fails.
        """
        (headers, data) = _Event.process(self)

        try:
            (h, m, s) = (int(v) for v in headers['Duration'].split(':'))
            headers['Duration'] = s + m * 60 + h * 60 * 60
        except Exception:
            headers['Duration'] = -1

        generic_transforms.to_int(headers, ('ChannelState', ), None)

        return (headers, data)
Esempio n. 35
0
 def process(self):
     """
     Translates the 'ChannelState' header's value into an int, setting it to `None` if coercion
     fails.
     
     Replaces the 'Duration' header's value with the number of seconds, as an int, or -1 if
     conversion fails.
     """
     (headers, data) = _Event.process(self)
     
     try:
         (h, m, s) = (int(v) for v in headers['Duration'].split(':'))
         headers['Duration'] = s + m * 60 + h * 60 * 60
     except Exception:
         headers['Duration'] = -1
         
     generic_transforms.to_int(headers, ('ChannelState',), None)
     
     return (headers, data)
Esempio n. 36
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
Esempio n. 37
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)
Esempio n. 38
0
 def process(self):
     """
     Translates the 'Abandoned', 'Calls', 'Completed', 'Holdtime', and 'Max' headers' values into
     ints, setting them to -1 on error.
     
     Translates the 'ServiceLevel', 'ServiceLevelPerf', and 'Weight' values into
     floats, setting them to -1 on error.
     """
     (headers, data) = _Event.process(self)
     generic_transforms.to_int(headers, (
         'Abandoned',
         'Calls',
         'Completed',
         'Holdtime',
         'Max',
     ), -1)
     generic_transforms.to_float(headers, (
         'ServiceLevel',
         'ServiceLevelPref',
         'Weight',
     ), -1)
     return (headers, data)
Esempio n. 39
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)
Esempio n. 40
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)
Esempio n. 41
0
    def process(self):
        """
        Translates the 'HighestSequence', 'LastSR', 'PacketsLost', 'ReceptionReports,
        and 'SequenceNumbercycles' 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 'From' into a tuple of IP:str and port:int, or sets it to `None` if the format is
        unknown.
        """
        (headers, data) = _Event.process(self)
        
        _from = headers.get('From')
        if _from and ':' in _from:
            headers['From'] = tuple(_from.rsplit(':', 1))
        else:
            headers['From'] = None
            
        generic_transforms.to_int(headers, ('HighestSequence', 'LastSR', 'PacketsLost', 'ReceptionReports', 'SequenceNumberCycles',), -1)
        headers['DLSR'] = (headers.get('DSLR') or '').split(' ', 1)[0]
        generic_transforms.to_float(headers, ('DLSR', 'FractionLost', 'IAJitter',), -1)
        
        return (headers, data)