Code Duplication    Length = 19-21 lines in 2 locations

doorpi/sipphone/linphone_lib/Recorder.py 1 location

@@ 27-47 (lines=21) @@
24
    @property
25
    def last_record_filename(self): return self.__last_record_filename
26
27
    def reset_last_record_filename(self):
28
        self.__last_record_filename = self.parsed_record_filename
29
        return self.__last_record_filename
30
31
    def __init__(self):
32
        self.__record_filename = DoorPi().config.get(SIPPHONE_SECTION, 'records',
33
                                                     '!BASEPATH!/records/%Y-%m-%d_%H-%M-%S.wav')
34
        if self.__record_filename is '':
35
            logger.debug('no recorder found in config at section DoorPi and key records')
36
            return
37
38
        DoorPi().event_handler.register_action('OnSipPhoneDestroy', self.destroy)
39
40
        DoorPi().event_handler.register_event('OnRecorderStarted', __name__)
41
        DoorPi().event_handler.register_event('OnRecorderStopped', __name__)
42
        DoorPi().event_handler.register_event('OnRecorderCreated', __name__)
43
44
        if DoorPi().config.get_bool(SIPPHONE_SECTION, 'record_while_dialing', 'False') is True:
45
            DoorPi().event_handler.register_action('OnSipPhoneMakeCall', self.start)
46
        else:
47
            DoorPi().event_handler.register_action('OnCallStateConnect', self.start)
48
49
        DoorPi().event_handler.register_action('OnCallStateDisconnect', self.stop)
50

doorpi/sipphone/pjsua_lib/Recorder.py 1 location

@@ 30-48 (lines=19) @@
27
    @property
28
    def last_record_filename(self): return self.__last_record_filename
29
30
    def __init__(self):
31
        self.__record_filename = DoorPi().config.get('DoorPi', 'records',
32
                                                     '!BASEPATH!/records/%Y-%m-%d_%H-%M-%S.wav')
33
        if self.__record_filename is '':
34
            logger.debug('no recorder found in config at section DoorPi and key records')
35
            return
36
37
        DoorPi().event_handler.register_event('OnRecorderStarted', __name__)
38
        DoorPi().event_handler.register_event('OnRecorderStopped', __name__)
39
        DoorPi().event_handler.register_event('OnRecorderCreated', __name__)
40
41
        if DoorPi().config.get_bool('DoorPi', 'record_while_dialing', 'False') is True:
42
            DoorPi().event_handler.register_action('OnSipPhoneMakeCall', self.start)
43
        else:
44
            DoorPi().event_handler.register_action('OnCallStateConnect', self.start)
45
46
        DoorPi().event_handler.register_action('OnCallStateDisconnect', self.stop)
47
48
        DoorPi().event_handler('OnRecorderCreated', __name__)
49
50
    def start(self):
51
        if self.__record_filename is '':