Ejemplo n.º 1
0
Archivo: uic.py Proyecto: cmft/taurus
        def load(self, fileOrName, parentWidget=None):
            if self._rootWidget is not None:
                raise Exception("UiLoader is already started loading UI!")

            widget = super(UiLoader, self).load(fileOrName, parentWidget)

            if widget != self._rootWidget:
                log.error("Qt: Returned widget isn't the root widget... ")

            self._rootWidget = None
            return widget
Ejemplo n.º 2
0
def __assertQt(name, qt=None, strict=True):
    qt = qt or __QT
    if name is None or qt is None:
        return
    qt_name = qt.__name__
    if qt_name != name:
        msg = "Cannot use %s because %s already in use" % (name, qt_name)
        if strict:
            raise Exception(msg)
        else:
            __log.error(msg)
Ejemplo n.º 3
0
        def load(self, fileOrName, parentWidget=None):
            if self._rootWidget is not None:
                raise Exception("UiLoader is already started loading UI!")

            widget = super(UiLoader, self).load(fileOrName, parentWidget)

            if widget != self._rootWidget:
                log.error("Qt: Returned widget isn't the root widget... ")

            self._rootWidget = None
            return widget
Ejemplo n.º 4
0
def __assertQt(name, qt=None, strict=True):
    qt = qt or __QT
    if name is None or qt is None:
        return
    qt_name = qt.__name__
    if qt_name != name:
        msg = "Cannot use %s because %s already in use" % (name, qt_name)
        if strict:
            raise Exception(msg)
        else:
            __log.error(msg)
Ejemplo n.º 5
0
Archivo: uic.py Proyecto: cmft/taurus
    def loadUI(uiFilename, parent=None):
        global __uiLoader
        if __uiLoader is None:
            __uiLoader = UiLoader()

        uiFile = __QtCore.QFile(uiFilename, parent)
        if not uiFile.open(__QtCore.QIODevice.ReadOnly):
            log.error("Qt: Couldn't open file %r!", uiFilename)
            return None

        try:
            return __uiLoader.load(uiFile, parent)

        except:
            log.exception("Exception loading UI from %r!", uiFilename)

        finally:
            uiFile.close()
            uiFile.deleteLater()

        return None
Ejemplo n.º 6
0
    def loadUI(uiFilename, parent=None):
        global __uiLoader
        if __uiLoader is None:
            __uiLoader = UiLoader()

        uiFile = __QtCore.QFile(uiFilename, parent)
        if not uiFile.open(__QtCore.QIODevice.ReadOnly):
            log.error("Qt: Couldn't open file %r!", uiFilename)
            return None

        try:
            return __uiLoader.load(uiFile, parent)

        except:
            log.exception("Exception loading UI from %r!", uiFilename)

        finally:
            uiFile.close()
            uiFile.deleteLater()

        return None
Ejemplo n.º 7
0
    def set(self, conf, mnt_grps=None):
        """Sets the ExperimentConfiguration dictionary."""
        env = dict(ScanDir=conf.get('ScanDir'),
                   ScanFile=conf.get('ScanFile'),
                   DataCompressionRank=conf.get('DataCompressionRank', -1),
                   ActiveMntGrp=conf.get('ActiveMntGrp'),
                   PreScanSnapshot=conf.get('PreScanSnapshot'))
        if mnt_grps is None:
            mnt_grps = conf['MntGrpConfigs'].keys()
        self._door.putEnvironments(env)

        codec = CodecFactory().getCodec('json')
        for mnt_grp in mnt_grps:
            try:
                mnt_grp_cfg = conf['MntGrpConfigs'][mnt_grp]
                if mnt_grp_cfg is None:  # a mntGrp to be deleted
                    pool = self._getPoolOfElement(mnt_grp)
                    pool.DeleteElement(mnt_grp)
                else:
                    try:
                        mnt_grp_dev = Device(mnt_grp)
                    except:  # if the mnt_grp did not already exist, create it now
                        chconfigs = getChannelConfigs(mnt_grp_cfg)
                        chnames, chinfos = zip(*chconfigs)  # unzipping
                        # We assume that all the channels belong to the same
                        # pool!
                        pool = self._getPoolOfElement(chnames[0])
                        pool.createMeasurementGroup([mnt_grp] + list(chnames))
                        mnt_grp_dev = Device(mnt_grp)

                    # TODO when we start using measurement group extension change the
                    # code below with the following:
                    # mnt_grp.setConfiguration(mnt_grp_cfg)
                    data = codec.encode(('', mnt_grp_cfg))[1]
                    mnt_grp_dev.write_attribute('configuration', data)
            except Exception, e:
                from taurus.core.util.log import error
                error(
                    'Could not create/delete/modify Measurement group "%s": %s',
                    mnt_grp, repr(e))
Ejemplo n.º 8
0
    def set(self, conf, mnt_grps=None):
        """Sets the ExperimentConfiguration dictionary."""
        env = dict(ScanDir=conf.get('ScanDir'),
                   ScanFile=conf.get('ScanFile'),
                   DataCompressionRank=conf.get('DataCompressionRank', -1),
                   ActiveMntGrp=conf.get('ActiveMntGrp'),
                   PreScanSnapshot=conf.get('PreScanSnapshot'))
        if mnt_grps is None:
            mnt_grps = conf['MntGrpConfigs'].keys()
        self._door.putEnvironments(env)

        codec = CodecFactory().getCodec('json')
        for mnt_grp in mnt_grps:
            try:
                mnt_grp_cfg = conf['MntGrpConfigs'][mnt_grp]
                if mnt_grp_cfg is None:  # a mntGrp to be deleted
                    pool = self._getPoolOfElement(mnt_grp)
                    pool.DeleteElement(mnt_grp)
                else:
                    try:
                        mnt_grp_dev = Device(mnt_grp)
                    except:  # if the mnt_grp did not already exist, create it now
                        chconfigs = getChannelConfigs(mnt_grp_cfg)
                        chnames, chinfos = zip(*chconfigs)  # unzipping
                        # We assume that all the channels belong to the same
                        # pool!
                        pool = self._getPoolOfElement(chnames[0])
                        pool.createMeasurementGroup([mnt_grp] + list(chnames))
                        mnt_grp_dev = Device(mnt_grp)

                    # TODO when we start using measurement group extension change the
                    # code below with the following:
                    # mnt_grp.setConfiguration(mnt_grp_cfg)
                    data = codec.encode(('', mnt_grp_cfg))[1]
                    mnt_grp_dev.write_attribute('configuration', data)
            except Exception, e:
                from taurus.core.util.log import error
                error(
                    'Could not create/delete/modify Measurement group "%s": %s', mnt_grp, repr(e))
Ejemplo n.º 9
0
Archivo: uic.py Proyecto: cmft/taurus
        def createWidget(self, className, parent=None, name=''):
            widget = super(UiLoader, self).createWidget(
                    className, parent, name)

            if name:
                if self._rootWidget is None:
                    self._rootWidget = widget
                elif not hasattr(self._rootWidget, name):
                    setattr(self._rootWidget, name, widget)
                else:
                    log.error("Qt: Name collision! Ignoring second "
                              "occurrance of %r.", name)

                if parent is not None:
                    setattr(parent, name, widget)
                else:
                    # Sadly, we can't reparent it to self, since QUiLoader
                    # isn't a QWidget.
                    log.error("Qt: No parent specified! This will probably "
                              "crash due to C++ object deletion.")

            return widget
Ejemplo n.º 10
0
        def createWidget(self, className, parent=None, name=''):
            widget = super(UiLoader,
                           self).createWidget(className, parent, name)

            if name:
                if self._rootWidget is None:
                    self._rootWidget = widget
                elif not hasattr(self._rootWidget, name):
                    setattr(self._rootWidget, name, widget)
                else:
                    log.error(
                        "Qt: Name collision! Ignoring second "
                        "occurrance of %r.", name)

                if parent is not None:
                    setattr(parent, name, widget)
                else:
                    # Sadly, we can't reparent it to self, since QUiLoader
                    # isn't a QWidget.
                    log.error("Qt: No parent specified! This will probably "
                              "crash due to C++ object deletion.")

            return widget