コード例 #1
0
ファイル: __init__.py プロジェクト: umithardal/nicos
 def doInit(self, mode):
     if requests is None:
         raise ConfigurationError(self, 'requests package is missing')
     self._prefix = self.prefix.strip('/')
     if self._prefix:
         self._prefix += '/'
     self._initFilters()
     self._queue = queue.Queue(1000)
     self._processor = createThread('webhookprocessor', self._processQueue)
コード例 #2
0
ファイル: motor.py プロジェクト: umithardal/nicos
    def _checkLimits(self, limits):
        # Called by doReadUserlimits and doWriteUserlimits
        low, high = self.abslimits
        if low == 0 and high == 0:
            # No limits defined in IOC.
            # Could be a rotation stage for example.
            return

        if limits[0] < low or limits[1] > high:
            raise ConfigurationError('cannot set user limits outside of '
                                     'absolute limits (%s, %s)' % (low, high))
コード例 #3
0
 def _name_server(self):
     tmp = self.config.split()
     if tmp[2].count(':') and not self.absdev:
         return tmp[2].split(':')[0]
     elif self.nameserver:
         return self.nameserver
     else:
         raise ConfigurationError(
             self, 'No name server configured. Please '
             'use the "nameserver" parameter or put it'
             'into the "config" parameter.')
コード例 #4
0
ファイル: setups.py プロジェクト: ess-dmsc/nicos
 def configdata(name):
     from nicos.core.errors import ConfigurationError
     try:
         setupname, element = name.split('.')
     except ValueError:
         raise ConfigurationError('configdata() argument must be in the '
                                  'form \'module.valuename\'') from None
     if setupname not in all_setups:
         raise ConfigurationError('config setup "%s" not found' % setupname)
     else:
         fullname = all_setups[setupname]
     ns = {}
     with open(fullname, encoding='utf-8') as fp:
         exec(fp.read(), ns)
     dep_files.add(fullname)
     try:
         return ns[element]
     except KeyError:
         raise ConfigurationError('value named %s not found in config setup'
                                  ' "%s"' % (element, setupname)) from None
コード例 #5
0
ファイル: caress.py プロジェクト: umithardal/nicos
 def doInit(self, mode):
     if mode == SIMULATION:
         return
     CARESSDevice.doInit(self, mode)
     if hasattr(self._caressObject, 'is_counting_module'):
         is_counting = \
             self._caress_guard(self._caressObject.is_counting_module,
                                self.cid)
     self.log.debug('counting module: %r', is_counting)
     if not is_counting:
         raise ConfigurationError(self, 'Object is not a measurable module')
コード例 #6
0
 def _checkLimits(self, limits):
     umin, umax = limits
     amin, amax = self.abslimits
     if isinstance(self, HasOffset):
         offset = getattr(self, '_new_offset', self.offset)
         umin += offset
         umax += offset
     else:
         offset = 0
     if umin > umax:
         raise ConfigurationError(
             self, 'user minimum (%s, offset %s) above the user '
             'maximum (%s, offset %s)' % (umin, offset, umax, offset))
     if umin < amin - abs(amin * 1e-12):
         raise ConfigurationError(
             self, 'user minimum (%s, offset %s) below the '
             'absolute minimum (%s)' % (umin, offset, amin))
     if umax > amax + abs(amax * 1e-12):
         raise ConfigurationError(
             self, 'user maximum (%s, offset %s) above the '
             'absolute maximum (%s)' % (umax, offset, amax))
コード例 #7
0
ファイル: generic.py プロジェクト: umithardal/nicos
 def __init__(self, parent, client, options):
     Panel.__init__(self, parent, client, options)
     self._error_window = None
     if 'uifile' not in options:
         raise ConfigurationError('GenericPanels require at least an'
                                  ' `uifile` option.')
     loadUi(self, findResource(options['uifile']))
     if options.get('showmsg'):
         self.client.message.connect(self.on_client_message)
     if client.isconnected:
         self.on_client_connected()
     client.connected.connect(self.on_client_connected)
コード例 #8
0
    def subscribe(self, topic):
        """ Create the thread that provides call backs on new messages
        """
        # Remove all the assigned topics
        self._consumer.unsubscribe()

        topics = self._consumer.topics()
        if topic not in topics:
            raise ConfigurationError('Provided topic %s does not exist' % topic)

        # Assign the partitions
        partitions = self._consumer.partitions_for_topic(topic)
        if not partitions:
            raise ConfigurationError('Cannot query partitions for %s' % topic)

        self._consumer.assign([kafka.TopicPartition(topic, p)
                               for p in partitions])
        self._stoprequest = False
        self._updater_thread = createThread('updater_' + topic,
                                            self._get_new_messages)
        self.log.debug('subscribed to updates from topic: %s' % topic)
コード例 #9
0
    def _initObject(self):
        if not self._orb:
            raise ProgrammingError(self, 'Programmer forgot to call _initORB')

        obj = self._orb.resolve_initial_references('NameService')
        _root_context = obj._narrow(CosNaming.NamingContext)

        if not _root_context:
            raise CommunicationError(
                self, 'Failed to narrow the root naming'
                ' context')
        if self._is_corba_device():
            try:
                tmp = self.objname.split('.') if self.objname else \
                    self.config.split()[2].split('.')
                if len(tmp) < 2:
                    tmp.append('caress_object')
                self.log.debug('%r', tmp)
                obj = _root_context.resolve(
                    [CosNaming.NameComponent(tmp[0], tmp[1])])
            except CosNaming.NamingContext.NotFound as ex:
                raise ConfigurationError(self,
                                         'Name not found: %s' % (ex, )) from ex
            self._caressObject = obj._narrow(CARESS.CORBADevice)
        else:
            try:
                self._caressObject = \
                    self._orb.string_to_object('corbaname::%s#%s.context/'
                                               'caress.context/'
                                               'server.context/absdev.object' %
                                               (self.nameserver, self.objname))
            except CORBA.BAD_PARAM as ex:
                raise ConfigurationError(self,
                                         'Name not found: %s' % (ex, )) from ex

        if CORBA.is_nil(self._caressObject):
            raise CommunicationError(self, 'Could not create a CARESS device')

        if hasattr(self._caressObject, 'init_module_orb'):
            self._caressObject.init_module = self._caressObject.init_module_orb
コード例 #10
0
    def doInit(self, mode):
        KafkaCacheDatabase.doInit(self, mode)

        if self.historytopic not in self._consumer.topics():
            raise ConfigurationError(
                'Topic "%s" does not exist. Create this topic and restart.' %
                self.historytopic)

        # Create the history consumer
        self._history_consumer = KafkaConsumer(bootstrap_servers=self.brokers)

        # Give up if the topic does not exist
        if self.historytopic not in self._history_consumer.topics():
            raise ConfigurationError(
                'Topic "%s" does not exist. Create this topic and restart.' %
                self.historytopic)

        # Assign the partitions
        partitions = self._history_consumer.partitions_for_topic(
            self.historytopic)
        self._history_consumer.assign(
            [TopicPartition(self.historytopic, p) for p in partitions])
コード例 #11
0
 def doInit(self, _mode):
     self._pilatus_detectors = []
     for det_name in self.detectors:
         if isinstance(session.getDevice(det_name), Detector):
             self._pilatus_detectors.append(session.getDevice(det_name))
         else:
             self.log.warning('non-pilatus detector %r uses pilatus image '
                              'file sink', det_name)
     if not self._pilatus_detectors:
         raise ConfigurationError(
             'pilatus data sink requires at least one pilatus detector '
             'device that is an instance of {}'.format(Detector)
         )
コード例 #12
0
ファイル: base.py プロジェクト: umithardal/nicos
    def doInit(self, mode):
        CARESSDevice.doInit(self, mode)
        if session.sessiontype == POLLER or mode == SIMULATION:
            return

        self._setROParam('_started', False)
        is_readable = True
        if hasattr(self._caressObject, 'is_readable_module'):
            is_readable = self._caress_guard(
                self._caressObject.is_readable_module, self.cid)

        if hasattr(self._caressObject, 'is_drivable_module'):
            is_drivable = self._caress_guard(
                self._caressObject.is_drivable_module, self.cid)
        elif self._device_kind() in [CORBA_DEVICE, 501]:
            # 500, 501 devices may be any combination of readable or drivable
            # Query capabilities from server
            (ret, _, _, chtype) = self._caress_guard(
                self._caressObject.readblock_params_orb, -0x80000000,
                self.cid, 1, 0, 0)
            if ret != READBLOCK_NORMAL or chtype != CHTYPE_INT32:
                # Something went wrong, assume no capabilities
                is_readable = False
                is_drivable = False
            else:
                (ret, _, dataseq) = self._caress_guard(
                    self._caressObject.int_readblock_module_orb, -0x80000000,
                    self.cid, 1, 1, ())
                if ret != READBLOCK_NORMAL or len(dataseq) != 1:
                    # Something went wrong, assume no capabilities
                    is_readable = False
                    is_drivable = False
                else:
                    is_readable = bool(dataseq[0] & DEVICE_READABLE)
                    is_drivable = bool(dataseq[0] & DEVICE_DRIVABLE)
                    # readable, drivable, counting, status, needs_reference,
                    # new_interface
        else:
            is_drivable = self._device_kind() in [3, 7, 13, 14, 15, 23, 24, 25,
                                                  28, 29, 30, 31, 32, 33, 37,
                                                  39, 40, 41, 43, 44, 45, 49,
                                                  50, 51, 53, 54, 56, 62, 67,
                                                  68, 70, 71, 72, 73, 76, 100,
                                                  103, 105, 106, 107, 108, 110,
                                                  111, 112, 114, 115, 123, 124,
                                                  125, 126]

        self.log.debug('readable module: %r', is_readable)
        self.log.debug('driveable module: %r', is_drivable)
        if not (is_drivable or is_readable):
            raise ConfigurationError(self, 'Object is not a moveable module')
コード例 #13
0
    def __init__(self, parent, client, options):
        Panel.__init__(self, parent, client, options)
        loadUi(self, findResource('nicos_mlz/gui/tunewavetable.ui'))

        self._dev = options.get('tabledev')
        measuremode = options.get('measuremode', 'nrse')
        if measuremode not in ['nrse', 'mieze']:
            measuremode = 'nrse'
        for i in range(self.measModeComboBox.count()):
            if measuremode == self.measModeComboBox.itemText(i):
                self.measModeComboBox.setCurrentIndex(i)
                break
        # access to the echotime device
        if not self._dev:
            raise ConfigurationError('TuneWaveTable panel: At least `tabledev`'
                                     ' is required.')

        self._header_labels = []
        self._available_tables = {}
        self._edit = None
        self._blocked_while_edit = [
            self.measModeComboBox, self.wavelengthComboBox,
            self.restorePushButton, self.savePushButton,
            self.refreshPushButton, self.deletePushButton
        ]

        self.tableWidget.installEventFilter(self)

        self.tableWidget.verticalHeader().setContextMenuPolicy(
            Qt.CustomContextMenu)

        self.measModeComboBox.currentIndexChanged.connect(self._fill_table)
        self.measModeComboBox.currentIndexChanged.connect(
            self._update_combo_boxes)
        self.wavelengthComboBox.currentIndexChanged.connect(self._fill_table)
        self.savePushButton.clicked.connect(self._save_current_table)
        self.refreshPushButton.clicked.connect(self._update_available_tables)
        self.tableWidget.verticalHeader()\
            .customContextMenuRequested.connect(
            self.on_tableWidget_customContextMenuRequested)
        self.tableWidget.cellActivated.connect(self._edit_cell)
        self.tableWidget.verticalHeader().sectionClicked.connect(
            self._stop_edit)
        self.tableWidget.horizontalHeader().sectionPressed.connect(
            self._stop_edit)
        self.tableWidget.setAlternatingRowColors(True)

        client.connected.connect(self.on_client_connected)
        client.device.connect(self.on_client_device)
        self._dev_available = False
コード例 #14
0
 def doStart(self, target):
     crystal = self._crystal(0)
     if not crystal:
         raise PositionError(self, 'Not valid setup')
     tthm = asin(target / (2 * self._d(0))) / pi * 360.
     plane = crystal.get(self.plane, None)
     if not plane:
         raise ConfigurationError(self, 'No valid mono configuration')
     omgm = tthm / 2.0 + plane[1] + plane[2]
     self.log.debug(self._attached_tthm, 'will be moved to %.3f' % tthm)
     self.log.debug(self._attached_omgm, 'will be moved to %.3f' % omgm)
     if self._attached_tthm.isAllowed(tthm) and \
        self._attached_omgm.isAllowed(omgm):
         self._attached_tthm.start(tthm)
         self._attached_omgm.start(omgm)
コード例 #15
0
 def doInit(self, mode):
     if mode == SIMULATION:
         return
     if not omniORB:
         raise ConfigurationError(self, 'There is no CORBA module found')
     self._initORB(
         ['-ORBInitRef',
          'NameService=corbaname::%s' % self._name_server()])
     self._initObject()
     _cid = self._getCID(self.config.split(None, 2)[0])
     self._init(_cid)
     if session.sessiontype != POLLER:
         # omniORB.setClientCallTimeout(self._caressObject, 0)
         self._setROParam('cid', _cid)
         if self._cache:
             self._cache.invalidate(self, 'cid')
コード例 #16
0
 def create(self, name, h5parent, sinkhandler):
     try:
         array = session.getDevice(self._array_name)
         if not isinstance(array, HistogramConfArray):
             raise ConfigurationError('%s is no HistogramConfArray' %
                                      self._array_name)
     except ConfigurationError:
         session.log.warning('Array %s not found, NOT stored',
                             self._array_name)
         return
     dset = h5parent.create_dataset(name, tuple(array.dim), 'float32')
     if self._scale != 1.:
         dset[...] = np.array(array.data, dtype='float32') * self._scale
     else:
         dset[...] = array.data
     self.createAttributes(dset, sinkhandler)
コード例 #17
0
ファイル: histogramdesc.py プロジェクト: umithardal/nicos
 def __init__(self, name, dtype, dims):
     shape = []
     dimnames = []
     dimunits = []
     dimbins = []
     for dim in dims:
         if not isinstance(dim, HistogramDimDesc):
             raise ConfigurationError('%s should be of type '
                                      'HistogramDimDesc' % dim)
         shape.append(dim.length)
         dimnames.append(dim.label)
         dimunits.append(dim.unit)
         dimbins.append(dim.bins)
     ArrayDesc.__init__(self, name, shape, dtype, dimnames)
     self.dimunits = dimunits
     self.dimbins = dimbins
     self.dimbins = dimbins
コード例 #18
0
ファイル: secop.py プロジェクト: umithardal/nicos
 def registerDevice(self, device):
     if not self._secnode:
         raise IOError('unconnected')
     self.log.debug('register %s on %s' % (device, self))
     self._devices[device.name] = device
     module = device.secop_module
     if module not in self._secnode.modules:
         raise ConfigurationError('no module %r found on this SEC node' % module)
     for parameter in self._secnode.modules[module]['parameters']:
         updatefunc = getattr(device, '_update_' + parameter, device._update)
         self._secnode.register_callback((module, parameter), updateEvent=updatefunc)
         try:
             data = self._secnode.cache[module, parameter]
             if data:
                 updatefunc(module, parameter, *data)
             else:
                 self.log.warning('No data for %s:%s' % (module, parameter))
         except KeyError:
             self.log.warning('No cache for %s:%s' % (module, parameter))
コード例 #19
0
ファイル: gkssjson.py プロジェクト: umithardal/nicos
 def _read_controller(self, keys):
     line = '_read_controller %s' % keys
     self.log.debug(line)
     try:
         data = requests.get(self.url, timeout=self.timeout).json()
         self.log.debug(data)
     except requests.Timeout as e:
         self.log.info(line)
         self.log.info('url %s' % self.url)
         self.log.info('err %s' % e)
         raise CommunicationError(self, 'HTTP Timeout failed')
     except Exception as e:
         self.log.info(line)
         self.log.info('url %s' % self.url)
         self.log.info('err %s' % e)
         raise ConfigurationError(self, 'HTTP request failed')
     res = {}
     for key in keys:
         res[key] = data[key]
     return res
コード例 #20
0
ファイル: caress.py プロジェクト: ess-dmsc/nicos
 def _init(self, cid):
     try:
         if not self._is_corba_device():
             raise ConfigurationError(
                 self, 'Must be configured as "CORBA_device" (ID=500)')
         _config = ' '.join(self.config.split()[3:])
         self.log.debug('reduced config: %s', _config)
         res = self._caressObject.init_module(INIT_NORMAL, cid, _config)
         self.log.debug('init module (Connect): %r', res)
         if res not in [(0, ON_LINE), (CARESS.OK, ON_LINE)]:
             res = self._caressObject.init_module(INIT_REINIT, cid, _config)
             self.log.debug('init module (Re-Init): %r', res)
             if res not in[(0, ON_LINE), (CARESS.OK, ON_LINE)]:
                 self.log.error('Init module (Re-Init): %r (%d, %s)',
                                res, cid, _config)
                 raise NicosError(self, 'Could not initialize module!')
         self._initialized = True
     except CORBA.TRANSIENT as err:
         raise CommunicationError(
             self, 'could not init CARESS module %r (%d: %s)' % (
                 err, cid, self.config)) from err
コード例 #21
0
ファイル: seccoll.py プロジェクト: umithardal/nicos
 def _generateSequence(self, target):
     seq = []
     if not self.isAtTarget(self.doRead(0)):
         # The limited space at some positions requires a folding of the
         # instrument
         st_target = 60. if self.angle > -85. else 109.
         if st_target != self.stpos:
             raise ConfigurationError(self, 'st_target != stpos')
         # Only move if the setup (folding of 'st') is not correctly
         if abs(self._attached_st.read(0) - self.stpos) > \
            self._attached_st.precision:
             seq.append(SeqDev(self._attached_tt, -60., stoppable=True))
             seq.append(
                 SeqDev(self._attached_st, self.stpos, stoppable=True))
         # the configured positions are with offet = 0 !
         # if the user changes the offset the change positions will not
         # change!
         tt_pos = self.angle - self._attached_tt.offset
         seq.append(SeqDev(self._attached_tt, tt_pos, stoppable=True))
         seq.append(SeqDev(self._attached_block, target))
         seq.append(SeqSleep(2))
     return seq
コード例 #22
0
    def doInit(self, mode):
        KafkaCacheDatabase.doInit(self, mode)

        if self.historytopic not in self._consumer.topics():
            raise ConfigurationError(
                'Topic "%s" does not exit. Create this topic and restart.' %
                self.historytopic)

        # Create the history consumer
        self._history_consumer = KafkaConsumer(bootstrap_servers=self.brokers)
        if self._history_consumer is None:
            raise CommunicationError("Can't connect to %s" % self.brokers)

        self.log.warning('%r' % self._history_consumer.topics())
        self.log.warning(
            '%r' %
            self._history_consumer.partitions_for_topic(self.historytopic))

        partitions = self._history_consumer.partitions_for_topic(
            self.historytopic)
        self._history_consumer.assign(
            [TopicPartition(self.historytopic, p) for p in partitions])
コード例 #23
0
 def __init__(self, slit_number, defaultval):
     if 0 < slit_number < 5:
         self.slit = slit_number
     else:
         raise ConfigurationError('Slit %s is out of range.' % slit_number)
     self.defaultval = defaultval
コード例 #24
0
 def doInit(self, mode):
     if len(self._attached_moveables) != 3:
         raise ConfigurationError('I need exactly 3 attached moveables, %d '
                                  'given' % len(self._attached_moveables))
     MultiSwitcher.doInit(self, mode)
コード例 #25
0
    def check(self, dev, aname, configargs):
        """Checks if the given arguments are valid for this entry.

        Also returns a list of all attached devices which should be created.
        May raise a configurationError, if something is wrongly configured.
        """
        def check_count(multiple, optional, count):
            if (count == 0) and optional:
                return True
            # Don't change it to more pythonic style since we want to check for
            # the boolean 'True' value
            if self.multiple is True:
                return count > 0
            return count in multiple

        if configargs:
            if isinstance(configargs, (tuple, list)):
                args = list(configargs)
            else:
                args = [configargs]
        else:
            args = []

        if self.single:
            if check_count(self.multiple, self.optional, len(args)):
                return args or [None]
            raise ConfigurationError(
                dev, "device misses device %r in "
                "configuration" % aname)

        # Don't change it to more pythonic style since we want to check for
        # the boolean 'True' value
        if self.multiple is True:
            if check_count(self.multiple, self.optional, len(args)):
                return args
            raise ConfigurationError(
                dev, "wrong number of devices (%d) for %r"
                " in configuration (specified=%r)" % (len(args), aname, args))

        # here we have:
        # - multiple is a list
        # - args has at least one real entry
        mindevs = min(self.multiple)
        maxdevs = max(self.multiple)
        # if optional, fill up to maxdevs with None
        if self.optional:
            args.extend([None] * (maxdevs - len(args)))

        # check number of devices
        if len(args) < mindevs:
            raise ConfigurationError(
                dev, "not enough devices (%d<%d) for %r"
                " in configuration (specified=%r)" %
                (len(args), mindevs, aname, args))
        if len(args) > maxdevs:
            raise ConfigurationError(
                dev, "too many devices (%d>%d) for %r in "
                "configuration (specified=%r)" %
                (len(args), maxdevs, aname, args))

        if check_count(self.multiple, self.optional, len(args)):
            return args
        raise ConfigurationError(
            dev, "wrong number of devices (%d) for %r in "
            "configuration (specified=%r)" % (len(args), aname, args))
コード例 #26
0
ファイル: datasinks.py プロジェクト: umithardal/nicos
 def doUpdateCommentchar(self, value):
     if len(value) > 1:
         raise ConfigurationError('comment character should only be one '
                                  'character')
コード例 #27
0
 def doWritePos(self, target):
     if target == 0:
         raise ConfigurationError(
             self, "'%d' is an invalid value for "
             "parameter 'pos'" % target)
     self._attached_translation.move(target)
コード例 #28
0
ファイル: secop.py プロジェクト: umithardal/nicos
    def makeDynamicDevices(self, setup_info):
        """create and destroy dynamic devices

        create devices from setup_info, and store the name of the setup
        creating the creator device in session.creator_devices for
        session.getSetupInfo()
        Based on the previous setup_info from self.setup_info,
        devices are created, recreated, destroyed or remain unchanged.
        If setup_info is empty, destroy all devices.
        """
        prevdevices = set(self.setup_info.keys())
        self._setROParam('setup_info', setup_info)

        # find setup of this secnode
        result = session.getSetupInfo()
        for setupname in session.loaded_setups:
            info = result.get(setupname, None)
            if info and self.name in info['devices']:
                break
        else:
            raise ConfigurationError('can not find setup')
        # add new or changed devices
        for devname, devcfg in setup_info.items():
            prevdevices.discard(devname)
            dev = session.devices.get(devname, None)
            if dev:
                if not isinstance(dev, SecopDevice) or (dev._attached_secnode and
                                                        dev._attached_secnode != self):
                    self.log.error('device %s already exists' % devname)
                    continue
                base = dev.__class__.__bases__[0]
                prevcfg = base.__module__ + '.' + base.__name__, dict(secnode=self.name, **dev._config)
            else:
                prevcfg = None
            if prevcfg != devcfg:
                session.configured_devices[devname] = devcfg
                session.dynamic_devices[devname] = setupname  # pylint: disable=undefined-loop-variable
                if dev is None:
                    # add new device
                    session.createDevice(devname, recreate=True, explicit=True)
                    dev = session.devices[devname]
                else:
                    # modify existing device
                    if dev._attached_secnode:
                        dev._attached_secnode.unregisterDevice(dev)
                    session.configured_devices[devname] = devcfg
                    session.dynamic_devices[devname] = setupname  # pylint: disable=undefined-loop-variable
                    try:
                        dev.replaceClass(devcfg[1])
                        dev.setAlive(self)
                    except ConfigurationError:
                        # above failed because an alias or attaching device requires a specific class
                        # make old device defunct and replace by a new device
                        session.destroyDevice(dev)
                        session.dynamic_devices.pop(devname, None)
                        session.createDevice(devname, recreate=True, explicit=True)
                        prevdevices.discard(devname)
                        dev = session.devices[devname]
                if not isinstance(dev, SecopReadable):
                    # we will not get status updates for these
                    dev.updateSecopStatus((SecopStatus.IDLE, ''))

        defunct = set()
        # defunct devices no longer available
        for devname in prevdevices:
            dev = session.devices.get(devname)
            if dev is None or dev._attached_secnode != self:
                continue
            if dev._sdevs:
                self.log.warning('defunct device is attached to %s' % ', '.join(dev._sdevs))
            dev.setDefunct()
            defunct.add(devname)

        # inform client that setups have changed
        session.setupCallback(list(session.loaded_setups), list(session.explicit_setups))
コード例 #29
0
ファイル: system.py プロジェクト: umithardal/nicos
 def doUpdateUnit(self, unit):
     factor = units.get(unit, None)
     if factor is None:
         raise ConfigurationError('Unsupported unit, allowed: %s' %
                                  ','.join(units))
     self._factor = factor
コード例 #30
0
ファイル: collimator.py プロジェクト: umithardal/nicos
 def doInit(self, mode):
     if self._attached_l.unit != self._attached_d.unit:
         raise ConfigurationError(
             self, 'different units for L and d '
             '(%s vs %s)' % (self._attached_l.unit, self._attached_d.unit))