Пример #1
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)
Пример #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)
Пример #3
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)
Пример #4
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)
Пример #5
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)
Пример #6
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)
Пример #7
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)
Пример #8
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)
Пример #9
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)
Пример #10
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)
Пример #11
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)
Пример #12
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)
Пример #13
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)
Пример #14
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)
Пример #15
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)
Пример #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)
Пример #17
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)
Пример #18
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)
Пример #19
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)
Пример #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)
Пример #21
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)
Пример #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)
Пример #23
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)
Пример #24
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)
Пример #25
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)
Пример #26
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)
Пример #27
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)
Пример #28
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)
Пример #29
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)
Пример #30
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)
Пример #31
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)
Пример #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)
Пример #33
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)
Пример #34
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)
Пример #35
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)
Пример #36
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)
Пример #37
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)
Пример #38
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)
Пример #39
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)
Пример #40
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)
Пример #41
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)
Пример #42
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)
Пример #43
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)
Пример #44
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)
Пример #45
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)