コード例 #1
0
    def _load_from_file(self, session_file):
        """ Load a saved session from file """
        try:
            with open(session_file, mode='r', encoding='utf-8') as file:
                session = json.load(file)

            # New session
            self._new_session(
                layouts.get_layout(session['application']['layout']))
            # Get the application settings
            self._app_conf = session['application']

            # Load cues
            for cue_conf in session['cues']:
                cue_type = cue_conf.pop('_type_', 'Undefined')
                cue_id = cue_conf.pop('id')
                try:
                    cue = CueFactory.create_cue(cue_type, cue_id=cue_id)
                    cue.update_properties(cue_conf)
                    self._cue_model.add(cue)
                except Exception as e:
                    elogging.exception('Unable to create the cue', e)

            MainActionsHandler.set_saved()
            self._mainWindow.update_window_title()

            # Load plugins settings
            plugins.set_plugins_settings(session['plugins'])

            # Update the main-window
            self._mainWindow.filename = session_file
            self._mainWindow.update()
        except Exception as e:
            elogging.exception('Error during file reading', e)
            self.new_session_dialog()
コード例 #2
0
    def new_session_dialog(self):
        """Show the layout-selection dialog"""
        try:
            # Prompt the user for a new layout
            dialog = LayoutSelect()
            if dialog.exec_() != QDialog.Accepted:
                if self._layout is None:
                    # If the user close the dialog, and no layout exists
                    # the application is closed
                    self.finalize()
                    qApp.quit()
                    exit()
                else:
                    return

            # If a valid file is selected load it, otherwise load the layout
            if exists(dialog.filepath):
                self._load_from_file(dialog.filepath)
            else:
                self._new_session(dialog.selected())

        except Exception as e:
            elogging.exception('Startup error', e)
            qApp.quit()
            exit(-1)
コード例 #3
0
ファイル: __init__.py プロジェクト: winstc/linux-show-player
def load_modules():
    for name, module in load_classes(__package__, os.path.dirname(__file__)):
        try:
            __MODULES[name] = module()
            elogging.debug('MODULES: Loaded "{0}"'.format(name))
        except Exception as e:
            elogging.exception('Failed "{0}" lading'.format(name), e)
コード例 #4
0
def reset_plugins():
    """Resets all the plugins."""
    for plugin in __PLUGINS:
        try:
            __PLUGINS[plugin].reset()
            elogging.debug('PLUGINS: Reset "{0}"'.format(plugin))
        except Exception as e:
            elogging.exception('PLUGINS: Failed "{0}" reset'.format(plugin), e)
コード例 #5
0
def load_plugins():
    """Load available plugins."""
    for name, plugin in load_classes(__package__, os.path.dirname(__file__)):
        try:
            __PLUGINS[name] = plugin()
            elogging.debug('PLUGINS: Loaded "{0}"'.format(name))
        except Exception as e:
            elogging.exception('PLUGINS: Failed "{0}" load'.format(name), e)
コード例 #6
0
ファイル: __init__.py プロジェクト: winstc/linux-show-player
def terminate_modules():
    for module_name in __MODULES:
        try:
            __MODULES[module_name].terminate()
            elogging.debug('MODULES: Terminated "{0}"'.format(module_name))
        except Exception as e:
            elogging.exception('Failed "{0}" termination'.format(module_name),
                               e)
コード例 #7
0
def set_plugins_settings(settings):
    for plugin in __PLUGINS.values():
        if plugin.Name in settings:
            try:
                plugin.load_settings(settings[plugin.Name])
            except Exception as e:
                elogging.exception(
                    'PLUGINS: Failed "{0}" settings load'.format(plugin.Name),
                    e)
コード例 #8
0
def init_plugins():
    """Initialize all the plugins."""
    failed = []
    for plugin in __PLUGINS:
        try:
            __PLUGINS[plugin].init()
            elogging.debug('PLUGINS: Initialized "{0}"'.format(plugin))
        except Exception as e:
            failed.append(plugin)
            elogging.exception('PLUGINS: Failed "{0}" init'.format(plugin), e)

    for plugin in failed:
        __PLUGINS.pop(plugin)
コード例 #9
0
    def add_cue(self, cue):
        item = QTreeWidgetItem()
        item.setTextAlignment(0, Qt.AlignCenter)

        for n, prop in enumerate(self._properties):
            try:
                item.setData(n, Qt.DisplayRole, getattr(cue, prop, 'Undefined'))
            except Exception as e:
                elogging.exception('Cannot display {0} property'.format(prop), e,
                                   dialog=False)

        self._cues[cue] = item
        item.setData(0, Qt.UserRole, cue)
        self.list.addTopLevelItem(item)
コード例 #10
0
def get_plugin_settings():
    plugins_settings = {}

    for plugin in __PLUGINS.values():
        try:
            settings = plugin.settings()
            if settings is not None and len(settings) > 0:
                plugins_settings[plugin.Name] = settings
        except Exception as e:
            elogging.exception(
                'PLUGINS: Failed "{0}" settings retrieve'.format(plugin.Name),
                e)

    return plugins_settings
コード例 #11
0
    def _add_peer(self, ip):
        port = config['Remote']['BindPort']
        uri = compose_http_url(ip, port)

        for peer in self.peers:
            if peer['uri'] == uri:
                QMessageBox.critical(
                    self, translate('SyncPeerDialog', 'Error'),
                    translate('SyncPeerDialog', 'Already connected'))
                return

        try:
            peer = {'proxy': RemoteController.connect_to(uri), 'uri': uri}
            self.peers.append(peer)
            self.listWidget.addItem(peer['uri'])
        except Exception as e:
            elogging.exception(translate('SyncPeerDialog', 'Cannot add peer'),
                               str(e))
コード例 #12
0
    def __send_timecode(self, time):
        tt = time_tuple(time)
        frame = int(tt[3] / self.__millis)

        if self.__hres:
            if self.__last_frame == frame:
                return
            self.__last_frame = frame

        try:
            if not self.__replace_hours:
                track = tt[0]
            else:
                track = self.__track

            self.__client.SendTimeCode(self.__format, track, tt[1], tt[2],
                                       frame)
        except OLADNotRunningException:
            self.stop_timecode(rclient=True, rcue=True)
            elogging.error(translate('Timecode', 'Cannot send timecode.'),
                           details=translate('Timecode', 'OLA has stopped.'))
        except Exception as e:
            self.stop_timecode(rclient=True, rcue=True)
            elogging.exception('Cannot send timecode.', e, dialog=False)