def configure_recording(): """Configures freeseer to record via REST server. Gets recording profiles and configuration and instantiates recording plugins. Then it restores any stored talks. Runs upon first call to REST server. """ recording.profile = settings.profile_manager.get() recording.config = recording.profile.get_config('freeseer.conf', settings.FreeseerConfig, storage_args=['Global'], read_only=True) recording.plugin_manager = PluginManager(recording.profile) recording.storage_file = os.path.join(settings.configdir, app.storage_file_path) media_info = shelve.open(recording.storage_file, writeback=True) recording.next_id = 1 recording.media_dict = {} for key, value in media_info.iteritems(): new_media = Multimedia(recording.config, recording.plugin_manager) if value['null_multimeda']: new_media.current_state = Multimedia.NULL else: # if null_multimeda is False, a video exists, set current_state to Multimedia.STOP new_media.current_state = Multimedia.STOP media_id = int(key) if media_id >= recording.next_id: recording.next_id = media_id + 1 if new_media.current_state == Multimedia.NULL: filename = value['filename'].split('.ogg')[0] success, filename = new_media.load_backend(None, filename) if not success: raise ServerError('Could not load multimedia backend') value['filename'] = filename value['filepath'] = new_media.plugman.get_plugin_by_name( new_media.config.record_to_file_plugin, "Output").plugin_object.location recording.media_dict[media_id] = new_media recording.media_info = media_info recording.media_info.sync()
def configure_recording(): """Configures freeseer to record via REST server. Gets recording profiles and configuration and instantiates recording plugins. Then it restores any stored talks. Runs upon first call to REST server. """ # setup the application so it exits gracefully signal.signal(signal.SIGINT, teardown_recording) recording.record_profile = settings.profile_manager.get() recording.record_config = recording.record_profile.get_config( 'freeseer.conf', settings.FreeseerConfig, storage_args=['Global'], read_only=True) recording.record_plugin_manager = PluginManager(recording.record_profile) recording.storage_file = os.path.join(settings.configdir, app.storage_file_path) recording.next_id = 1 # restore talks from storage if os.path.isfile(recording.storage_file): with open(recording.storage_file) as fd: persistent = json.loads(fd.read()) recording.media_dict = {} for key in persistent: new_media = Multimedia(recording.record_config, recording.record_plugin_manager) new_media.current_state = persistent[key]['status'] media_id = int(key) if new_media.current_state == Multimedia.NULL: filename = persistent[key]['filename'].split(".ogg")[0] success, filename = new_media.load_backend(None, filename) if success: filepath = new_media.plugman.get_plugin_by_name( new_media.config.record_to_file_plugin, "Output").plugin_object.location recording.media_dict[media_id] = { 'media': new_media, 'filename': filename, 'filepath': filepath } else: raise ServerError('Could not load multimedia backend') else: recording.media_dict[media_id] = { 'media': new_media, 'filename': persistent[key]['filename'], 'filepath': persistent[key]['filepath'] } # sets next_id to last index of persistent + 1 recording.next_id = len(persistent) else: # if no talks to restore, make empty media_dict, set next_id to 1 recording.media_dict = {} recording.next_id = 1
def configure_recording(): """Configures freeseer to record via REST server. Gets recording profiles and configuration and instantiates recording plugins. Then it restores any stored talks. Runs upon first call to REST server. """ recording.profile = settings.profile_manager.get() recording.config = recording.profile.get_config('freeseer.conf', settings.FreeseerConfig, storage_args=['Global'], read_only=True) recording.plugin_manager = PluginManager(recording.profile) recording.storage_file = os.path.join(settings.configdir, app.storage_file_path) media_info = shelve.open(recording.storage_file, writeback=True) recording.next_id = 1 recording.media_dict = {} for key, value in media_info.iteritems(): new_media = Multimedia(recording.config, recording.plugin_manager) if value['null_multimeda']: new_media.current_state = Multimedia.NULL else: # if null_multimeda is False, a video exists, set current_state to Multimedia.STOP new_media.current_state = Multimedia.STOP media_id = int(key) if media_id >= recording.next_id: recording.next_id = media_id + 1 if new_media.current_state == Multimedia.NULL: filename = value['filename'].split('.ogg')[0] success, filename = new_media.load_backend(None, filename) if not success: raise ServerError('Could not load multimedia backend') value['filename'] = filename value['filepath'] = new_media.plugman.get_plugin_by_name(new_media.config.record_to_file_plugin, "Output").plugin_object.location recording.media_dict[media_id] = new_media recording.media_info = media_info recording.media_info.sync()
def configure_recording(): """Configures freeseer to record via REST server. Gets recording profiles and configuration and instantiates recording plugins. Then it restores any stored talks. Runs upon first call to REST server. """ # setup the application so it exits gracefully signal.signal(signal.SIGINT, teardown_recording) recording.record_profile = settings.profile_manager.get() recording.record_config = recording.record_profile.get_config('freeseer.conf', settings.FreeseerConfig, storage_args=['Global'], read_only=True) recording.record_plugin_manager = PluginManager(recording.record_profile) recording.storage_file = os.path.join(settings.configdir, app.storage_file_path) recording.next_id = 1 # restore talks from storage if os.path.isfile(recording.storage_file): with open(recording.storage_file) as fd: persistent = json.loads(fd.read()) recording.media_dict = {} for key in persistent: new_media = Multimedia(recording.record_config, recording.record_plugin_manager) new_media.current_state = persistent[key]['status'] media_id = int(key) if new_media.current_state == Multimedia.NULL: filename = persistent[key]['filename'].split(".ogg")[0] success, filename = new_media.load_backend(None, filename) if success: filepath = new_media.plugman.get_plugin_by_name(new_media.config.record_to_file_plugin, "Output").plugin_object.location recording.media_dict[media_id] = { 'media': new_media, 'filename': filename, 'filepath': filepath } else: raise ServerError('Could not load multimedia backend') else: recording.media_dict[media_id] = { 'media': new_media, 'filename': persistent[key]['filename'], 'filepath': persistent[key]['filepath'] } # sets next_id to last index of persistent + 1 recording.next_id = len(persistent) else: # if no talks to restore, make empty media_dict, set next_id to 1 recording.media_dict = {} recording.next_id = 1
def configure(storage_file): app.record_profile = settings.profile_manager.get() app.record_config = app.record_profile.get_config('freeseer.conf', settings.FreeseerConfig, ['Global'], read_only=True) app.record_plugin_manager = PluginManager(app.record_profile) app.storage_file = os.path.join(settings.configdir, storage_file) app.next_id = 1 # restore talks from storage if os.path.isfile(app.storage_file): with open(app.storage_file) as fd: persistant = json.loads(fd.read()) app.media_dict = {} for key in persistant: new_media = Multimedia(app.record_config, app.record_plugin_manager) new_media.current_state = persistant[key]['status'] int_key = int(key) if new_media.current_state == Multimedia.NULL: filename = persistant[key]['filename'].split(".ogg")[0] success, filename = new_media.load_backend(None, filename) if success: filepath = new_media.plugman.get_plugin_by_name(new_media.config.record_to_file_plugin, "Output").plugin_object.location app.media_dict[int_key] = { 'media': new_media, 'filename': filename, 'filepath': filepath } else: raise ServerError('Could not load multimedia backend') else: app.media_dict[int_key] = { 'media': new_media, 'filename': persistant[key]['filename'], 'filepath': persistant[key]['filepath'] } if int_key >= app.next_id: app.next_id = int_key + 1 else: app.media_dict = {}