from core.exceptions.session_exceptions import IllegalSessionStateException from core.helpers.data_transformer import DataTransformer from core.helpers.loggers import LoggerHelper from core.helpers.mongo import MongoHelper from core.helpers.validators import GenericValidator from core.helpers.video_helper import VideoEditorHelper from core.model.rumba_session import RumbaSession from core.model.session_status import SessionStatus from core.model.video import Video from core.services.fs_manager import FileSystemService from core.services.session_manager import SessionManager from core.services.video.video_threads_manager import VideoThreadsManager from core.threads.dasher_splitter_thread import DasherSplitterThread from core.threads.thumbs_thread import ThumbsCreatorThread LOGGER = LoggerHelper.get_logger("video_manager", "video_manager.log") THUMBS_OUTPUT_DIR_NAME = "thumbs" CONFIG = configparser.RawConfigParser() CONFIG.read('backend.cfg') class VideoManager(object): __instance = None def __init__(self): if VideoManager.__instance is not None: raise Exception("This class is a singleton.") else: VideoManager.__instance = self
""" Module containing a REST API defining endpoints for the management of audio in the sessions. """ from flask import Blueprint, jsonify from pymongo import MongoClient from core.helpers.loggers import LoggerHelper from core.services.audio_manager import AudioManager LOGGER = LoggerHelper.get_logger("api", "api.log") AUDIO_API = Blueprint("audio_api", __name__, url_prefix="/api/audio") CLIENT = MongoClient() DB = CLIENT['rumba'] @AUDIO_API.route("/microphone/state", methods=["GET"]) def get_mic_state(): """ Endpoint for querying if the microphone is connected to the server through the Jack port or not. :return: """ LOGGER.info("Received request for getting microphone state.") db_entry = DB.mic_state.find_one() if db_entry is None: status = 'unknown' else: status = db_entry['state'] LOGGER.info("Microphone state request successfully finished: [state={}]".format(status)) return jsonify({'state': status}),200
import re import subprocess import uuid from threading import Thread from time import sleep from core.exceptions.generic_exceptions import NotExistingResource from core.helpers.data_transformer import DataTransformer from core.helpers.loggers import LoggerHelper from core.helpers.video_helper import VideoEditorHelper from core.model.rumba_session import RumbaSession from core.services.audio_manager import AudioManager from core.threads.audio_splitter_thread import AudioSplitterThread from core.threads.audio_video_mixer_thread import AudioVideoMixerThread LOGGER = LoggerHelper.get_logger("video_editor", "video_editor.log") class VideoEditorThread(Thread): edition_info_filename = None output_file = None command = None code = None def __init__(self, edition_info_file, output_file, edit_info, edition_id): super(VideoEditorThread, self).__init__() self.edit_info = edit_info self.edition_id = edition_id self.edition_info_filename = edition_info_file self.output_file = output_file
import time from threading import Thread from core.helpers.loggers import LoggerHelper from core.model.process_status import ProcessStatus from core.model.video import Video from core.services.video.video_threads_repository import VideoThreadsRepository LOGGER = LoggerHelper.get_logger("monitor", "thread_monitoring.log") class MonitoringThread(Thread): thread_repos = None polling_interval = 10 def __init__(self, polling_interval=None): super(MonitoringThread, self).__init__() self.thread_repos = VideoThreadsRepository.get_instance() if polling_interval is not None and type(polling_interval) == int: self.polling_interval = polling_interval def run(self): while True: LOGGER.info("Starting thread monitoring.") self.__check_thumbs_threads__() self.__check_splitter_threads() LOGGER.info( "Thread monitoring finished. Sleeping {} seconds.".format( self.polling_interval)) time.sleep(self.polling_interval)
import configparser from core.exceptions.generic_exceptions import NotExistingResource from core.exceptions.session_exceptions import SessionValidationException, \ IllegalSessionStateException from core.helpers.loggers import LoggerHelper from core.helpers.mongo import MongoHelper from core.helpers.validators import SessionValidator, GenericValidator, FilesValidator from core.model.rumba_session import RumbaSession from core.model.session_status import SessionStatus from core.services.audio_manager import AudioManager from core.services.fs_manager import FileSystemService LOGGER = LoggerHelper.get_logger("session_manager", "session_manager.log") CONFIG = configparser.RawConfigParser() CONFIG.read('backend.cfg') SERVER_URL = CONFIG.get("server", "server_url") if SERVER_URL[-1] != "/": SERVER_URL = SERVER_URL + "/" class SessionManager(object): __instance = None def __init__(self): if SessionManager.__instance is not None: raise Exception("This class is a singleton.") else: SessionManager.__instance = self
import zipfile from io import BytesIO from os import makedirs from core.exceptions.generic_exceptions import NotExistingResource from core.exceptions.session_exceptions import IllegalSessionStateException, \ SessionValidationException from core.helpers.files import FilesHelper from core.helpers.loggers import LoggerHelper from core.helpers.validators import GenericValidator CONFIG = configparser.RawConfigParser() CONFIG.read('backend.cfg') LOGGER = LoggerHelper.get_logger("fs_manager", "fs_manager.log") class FileSystemService(object): """ This class is responsible of interacting with the server File System The FileSystemService service is a singleton class for performing actions on the server's file system. """ directory = None __instance = None def __init__(self): if FileSystemService.__instance is not None: raise Exception("This class is a singleton.")