def __init__(self, control_app, app, ui, logging_queue): super(ServiceManager, self).__init__() # global LOGGER # LOGGER = setup_queued_logger(__name__, logging_queue) self.control_app, self.app, self.ui = control_app, app, ui self.job_working_queue = list() self.job_queue = list() self.empty_job = Job(_('Kein Job'), '', get_user_directory(), 'mayaSoftware') self.current_job = self.empty_job # Control app signals self.start_job_signal.connect(self.control_app.add_render_job) self.job_widget_signal.connect(self.control_app.update_job_widget) self.abort_running_job_signal.connect( self.control_app.abort_running_job) self.force_psd_creation_signal.connect( self.control_app.watcher_force_psd_creation) # Run service manager socket server self.server = None self.address = ('', 0) self.hostname = '' # Timer's must be created inside thread event loop, I guess... self.alive_led_timer = None self.validate_queue_timer = None
def __init__(self, app, ui, logging_queue): """ :param modules.main_app.PfadAeffchenApp app: :param ui: :param logging_queue: """ super(ControlApp, self).__init__(ui=ui) global LOGGER LOGGER = setup_queued_logger(__name__, logging_queue) self.app, self.ui, self.logging_queue = app, ui, logging_queue self.scene_file = None self.render_path = None self.job_aborted = False self.mod_dir = self.app.mod_dir self.job_finished_timer.timeout.connect(self.job_finished) # Initialise Main Window self.ui.actionToggleWatcher.toggled.connect(self.toggle_watcher_window) self.ui.enableQueue.toggled.connect(self.start_queue) self.ui.startRenderService.toggled.connect(self.toggle_render_service) self.ui.actionReport.triggered.connect(self.save_status_report) self.ui.lineEditSubnet.editingFinished.connect( self.update_valid_ip_subnet_patterns) # Setup renderer ComboBox and set default to mayaSoftware 0 setup_combo_box(self.ui.comboBox_renderer, AVAILABLE_RENDERER, 0) # Setup Maya version ComboBox and set default to highest version found available_maya_versions = get_available_versions() self.update_status( _('Installierte Maya Versionen: {}').format( available_maya_versions)) setup_combo_box(self.ui.comboBox_version, available_maya_versions) # Setup socket server to receive status updates self.server = run_message_server( (self.update_status, self.led_socket_recv_start, self.led_socket_recv_end)) self.layer_creation_thread = None # Create default job self.empty_job = Job(_('Kein Job'), '', get_user_directory(), self.ui.comboBox_renderer.currentText()) self.current_job = self.empty_job # Setup socket send self.socket_send = SendMessage() self.socket_send.send_started.connect(self.led_socket_send_start) self.socket_send.send_ended.connect(self.led_socket_send_end) self.socket_send.send_error.connect(self.led_socket_send_error) # GUI Feedback we are alive and running self.alive_job_timer.timeout.connect(self.alive_job_blink) self.init_network_render_service()
def create_local_work_dir(cls) -> str: local_work_dir = os.path.join(get_user_directory(), '_work') if cls.create_dir(local_work_dir): return local_work_dir return str()
def init_network_render_service(self): """ Start the image watcher process and the job service manager """ if not self.render_path: self.render_path = get_user_directory() self.start_service_manager()
def setup_log_file(log_file_name=PFAD_AEFFCHEN_LOG_NAME, delete_existing_log_files=False): """ This should only be called once. It configures the logging module. All sub processes and threads inherit their settings from this configuration. """ usr_profile = get_user_directory() log_file = os.path.join(usr_profile, log_file_name) if delete_existing_log_files: delete_existing_logs(log_file) log_conf = { 'version': 1, 'disable_existing_loggers': True, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%(asctime)s %(module)s: %(message)s' }, 'file_formatter': { 'format': '%(asctime)s - %(module)s: %(message)s' }, }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'stream': 'ext://sys.stdout', 'formatter': 'simple' }, 'file': { 'level': 'DEBUG', 'class': 'logging.handlers.RotatingFileHandler', 'filename': LOG_FILE, 'maxBytes': 5000000, 'backupCount': 4, 'formatter': 'file_formatter', }, 'null': { 'level': 'DEBUG', 'class': 'logging.NullHandler', 'formatter': 'file_formatter', } }, 'loggers': { 'aeffchen_logger': { 'handlers': ['file', 'console'], 'propagate': False, 'level': 'INFO', }, 'watcher_logger': { 'handlers': ['file', 'console'], 'propagate': False, 'level': 'DEBUG', }, # Module loggers '': { 'handlers': ['file', 'console'], 'propagate': False, 'level': 'DEBUG', } } } logging.config.dictConfig(log_conf)
# Available from Python >3.2 from logging.handlers import QueueHandler, QueueListener except ImportError: pass try: from logging.handlers import RotatingFileHandler except ImportError: pass import logging.config from datetime import datetime from modules.app_globals import PFAD_AEFFCHEN_LOG_NAME from modules.setup_paths import get_user_directory LOG_FILE = os.path.join(get_user_directory(), PFAD_AEFFCHEN_LOG_NAME) def setup_log_file(log_file_name=PFAD_AEFFCHEN_LOG_NAME, delete_existing_log_files=False): """ This should only be called once. It configures the logging module. All sub processes and threads inherit their settings from this configuration. """ usr_profile = get_user_directory() log_file = os.path.join(usr_profile, log_file_name) if delete_existing_log_files: delete_existing_logs(log_file) log_conf = { 'version': 1, 'disable_existing_loggers': True,