Esempio n. 1
0
    def run(self):
        s = socket(AF_INET, SOCK_DGRAM)  # create UDP socket
        s.bind(('', 0))
        s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)  # this is a broadcast socket
        my_ip = get_valid_network_address()  # get our IP. Be careful if you have multiple network interfaces or IPs

        # MS Windows 10 workaround, use IP x.x.x.255 instead of b'<broadcast>'
        ip = get_valid_network_address()
        ip = ip.split('.')

        broadcast_ip = f'{ip[0]}.{ip[1]}.{ip[2]}.255'
        LOGGER.info('Announcing service %s at ip %s with %s', self.magic, my_ip, broadcast_ip)
        broadcast_ip.encode()

        send_message(_('Pfad Aeffchen Dienst wird unter der Adresse {}:{} angeboten').format(my_ip, self.port))

        while not self.exit_event.is_set():
            data = self.magic + my_ip
            data = data.encode(encoding='utf-8')

            s.sendto(data, (broadcast_ip, self.port))
            self.announce_signal.emit()

            self.exit_event.wait(timeout=self.announce_interval)

        s.close()
Esempio n. 2
0
    def file_created(self, file_set, img_num):
        msg = _('Bilddatei erstellt: ') + str(file_set)
        send_message(msg)

        # Report total number of created images to main app
        send_message(f'COMMAND IMG_NUM {img_num:04d}')
        self.signal_receiver(msg)
Esempio n. 3
0
    def closeEvent(self, QCloseEvent):
        if not self.app.app_closing:
            QCloseEvent.ignore()
            send_message('COMMAND TOGGLE_WATCHER')
            return

        QCloseEvent.accept()
Esempio n. 4
0
    def check_arnold_render_output(line: str):
        """
            Receives batch render process output for rendering status
            Arnold prints "0% done" status
        """
        match = r'(\d+)(\%\sdone)'
        m = re.search(match, line)

        if m and m.groups():
            percent = m.groups()[0]
            if isinstance(percent, str) and percent.isdigit():
                p = int(percent)
                if not p % 10:  # Update on every 10 percent progress
                    img_num = 1 + round(p * 0.1)
                    send_message(f'COMMAND IMG_NUM {img_num}')
Esempio n. 5
0
 def psd_created():
     send_message(_('PSD Erstellung abgeschlossen.'))
     send_message('COMMAND IMG_JOB_FINISHED')
Esempio n. 6
0
 def img_job_failed():
     """ Called if zero images detected for psd creation """
     send_message(_('Keine Bilddaten gefunden fuer PSD Erstellung.'))
     send_message('COMMAND IMG_JOB_FAILED')
Esempio n. 7
0
 def file_removed(self, file_set):
     msg = 'Bilddatei entfernt: ' + str(file_set)
     send_message(msg)
     self.signal_receiver(msg)
def main():
    LOGGER.debug('Running in batch: %s', pm.about(batch=True))

    # Prepare file paths
    base_dir = os.path.dirname(args.file_path)
    scene_name = os.path.splitext(os.path.basename(args.file_path))[0]
    scene_ext = os.path.splitext(args.file_path)[1]
    render_scene_name = scene_name + '_render.mb'
    render_scene_file = os.path.join(base_dir, render_scene_name)

    # Set rendering path
    img_path = os.path.abspath(args.render_path)

    # Create rendering dir
    if not os.path.exists(img_path):
        try:
            os.mkdir(img_path)
            send_message('Erstelle Ausgabe Verzeichnis:<i>' +
                         os.path.split(img_path)[-1] + '</i>')
        except Exception as e:
            LOGGER.error(e)
            send_message(
                'Konnte Ausgabeverzeichnis nicht erstelllen/zugreifen.')
            sys.exit(1)

    # --- Prepare CSB import
    if scene_ext.capitalize() == '.csb':
        if not load_csb_plugin(args.version):
            LOGGER.fatal(
                'Could not load rttDirectMayaPlugIn. Can not import CSB files. Aborting batch process.'
            )
            send_message(
                'Konnte rttDirectMayaPlugIn nicht laden. Vorgang abgebrochen.')
            sys.exit(2)

    # --- Prepare Arnold Renderer PlugIn
    if args.renderer == 'arnold':
        if not load_mtoa_plugin():
            LOGGER.fatal(
                'Could not load mtoa. Can not render using arnold. Aborting batch process.'
            )
            send_message(
                'Konnte Arnold Renderer nicht laden. Vorgang abgebrochen.')
            sys.exit(3)

    # Open or import file
    if scene_ext.capitalize() == '.csb':
        # Import CSB File
        send_message('Importiere CSB Szenendatei:<br><i>' + scene_name +
                     '</i>')
        send_message('COMMAND STATUS_NAME Importiere CSB Datei')
        mfu.import_csb(args.file_path, args.csb_ignore_hidden)
    elif scene_ext.capitalize() == '.mb':
        # Load maya binary
        send_message('Oeffne Maya Binaere Szenendatei:<br><i>' + scene_name +
                     '</i>')
        send_message('COMMAND STATUS_NAME Importiere Maya Binary')
        mfu.open_file(args.file_path)

    # Check for DeltaGen camera "Camera"
    if not mu.get_camera_by_name('Camera') and not args.use_scene_settings:
        send_message(
            'Keine renderbare Kamera - "Camera" gefunden! Vorgang abgebrochen.'
        )
        LOGGER.fatal(
            'Renderable Camera with exact name "Camera" could not be found. Aborting layer creation.'
        )
        sys.exit(4)

    # Setup scene with foreground matte layers per material
    send_message('Erstelle render layer setup.')
    send_message('COMMAND STATUS_NAME Erstelle Render-Layer Setup')
    num_layers = maya_matte_layers.create(
        maya_delete_hidden=args.maya_delete_hidden,
        renderer=args.renderer,
        use_scene_settings=args.use_scene_settings)
    send_message('{:04d} Layer erstellt.'.format(num_layers))
    send_message('COMMAND LAYER_NUM {:04d}'.format(num_layers))

    # Setup render settings
    send_message('Setze ' + args.renderer + ' Einstellungen.')
    if not args.use_scene_settings:
        maya_render_settings.setup_render_settings('Camera', img_path,
                                                   args.env, args.renderer)
    if args.use_scene_settings and args.renderer == 'arnold':
        # Make sure scene arnold settings have log level set to info
        maya_render_settings.setup_minimal_mtoa()

    # Save the scene
    mfu.save_file(render_scene_file)
    send_message('Rendering Szenendatei erstellt:<br><i>' + render_scene_file +
                 '</i>')

    # Close the scene
    mfu.new_file()
    send_message('Szene entladen. Ressourcen freigegeben.')
    send_message('COMMAND STATUS_NAME Rendering Szene erstellt')
Esempio n. 9
0
    def delete_empty_images_threaded(cls,
                                     img_path,
                                     img_ext=ImgParams.extension,
                                     env=''):
        """ Obsolete with Image Watcher process """
        """
            Check for empty images in own Maya Standalone threads
        """
        def join_threads(thread_list):
            if not len(thread_list):
                return

            LOGGER.info('Joining %s threads', len(thread_list))

            while thread_list:
                __thread = thread_list.pop()
                __timeout = time()

                while __thread.isAlive():
                    LOGGER.info('Joining %s', __thread.getName())
                    __thread.join(timeout=120.0)

                    if time() - __timeout > 600.0:
                        LOGGER.error('Thread %s timed out.',
                                     __thread.getName())
                        break

        def cpu_count(num_cpu=6):
            if 'NUMBER_OF_PROCESSORS' in os.environ.keys():
                __os_cpu = int(os.environ['NUMBER_OF_PROCESSORS'])
                num_cpu = max(1, int(round(__os_cpu * 0.5)))

            return num_cpu

        # Start time
        __s = time()
        # Image list
        __img_list = list()
        # Check image thread helper class
        __cs = CheckImageThread
        # Number of threads allowed
        __num_cpu = cpu_count()

        # Create list of image files
        for __i in cls.iter_image_files(img_path, img_ext):
            __img_list.append(__i)

        send_message(
            'Bilderkennung benutzt {0} Threads fuer {1} Bilder'.format(
                __num_cpu, len(__img_list)))
        LOGGER.info('======================================')
        LOGGER.info('Starting empty image detection')
        LOGGER.info('using %s threads for %s images', __num_cpu,
                    len(__img_list))
        LOGGER.info('======================================')

        # Prepare thread list
        __t = list()

        # Create thread per image
        while __img_list:
            __img = __img_list.pop()

            # Create thread
            __img_thread = __cs(__img, env)
            __img_thread.setDaemon(False)
            __img_thread.start()

            __t.append(__img_thread)

            __img_name = os.path.split(__img)[-1]
            LOGGER.info('Started image detection thread #%s/%s for image %s',
                        max(0, len(__t)), __num_cpu, __img_name)
            send_message('Starte Thread {0}/{1} fuer Datei:<i> {2}</i>'.format(
                max(0, len(__t)), __num_cpu, __img_name))

            # Have a break while a new maya standalone initializes
            sleep(3)

            if len(__t) >= __num_cpu:
                join_threads(__t)

        join_threads(__t)

        # Report duration
        __duration = time() - __s
        __m, __s = divmod(__duration, 60)
        LOGGER.info('Image detection duration: {:02.0f}:{:02.0f}'.format(
            __m, __s))
        send_message(
            'Bilderkennung abgeschlossen in {:02.0f}min:{:02.0f}sec'.format(
                __m, __s))