is_active()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
import logging
5
logger = logging.getLogger(__name__)
6
logger.debug("%s loaded", __name__)
7
8
def get(*args, **kwargs):
0 ignored issues
show
Unused Code introduced by Thomas
The argument args seems to be unused.
Loading history...
9
    try:
10
        if len(kwargs['name']) == 0: kwargs['name'] = ['']
11
        if len(kwargs['value']) == 0: kwargs['value'] = ['']
12
13
        sipphone = kwargs['DoorPiObject'].sipphone
14
15
        status = {}
16
        for name_requested in kwargs['name']:
17
            status = {}
18
            sipphone.thread_register('status_thread')
19
20
            if name_requested in 'name':
21
                status['name'] = sipphone.name
22
23
            if name_requested in 'sound_codecs':
24
                status['sound_codecs'] = sipphone.sound_codecs
25
            if name_requested in 'sound_devices':
26
                status['sound_devices'] = sipphone.sound_devices
27
28
            if name_requested in 'sound_enable':
29
                if len(sipphone.sound_codecs) and len(sipphone.sound_devices):
30
                    status['sound_enable'] = True
31
                else:
32
                    status['sound_enable'] = False
33
34
            if name_requested in 'video_codecs':
35
                status['video_codecs'] = sipphone.video_codecs
36
            if name_requested in 'video_devices':
37
                status['video_devices'] = sipphone.video_devices
38
39
            if name_requested in 'video_enable':
40
                if len(sipphone.video_codecs) and len(sipphone.video_devices):
41
                    status['video_enable'] = True
42
                else:
43
                    status['video_enable'] = False
44
45
            if name_requested in 'recorder':
46
                status['has_recorder'] = True if sipphone.recorder else False
47
                if status['has_recorder']:
48
                    status['recorder_filename'] = sipphone.recorder.record_filename
49
                    status['recorder_parsed_filename'] = sipphone.recorder.parsed_record_filename
50
51
            if name_requested in 'player':
52
                status['has_player'] = True if sipphone.player else False
53
                if status['has_player']:
54
                    status['player_filename'] = sipphone.player.player_filename
55
56
            if name_requested in 'current_call':
57
                status['current_call'] = sipphone.current_call_dump
58
59
        return status
60
    except Exception as exp:
61
        logger.exception(exp)
62
        return {'Error': 'could not create '+str(__name__)+' object - '+str(exp)}
63
64
def is_active(doorpi_object):
65
    return True if doorpi_object.sipphone else False
66