def __get_t4_name(self, item): scheme = getSchemeFromName(item) f = Factory(scheme=scheme) element_types = f.getValidTypesForName(item) if TaurusElementType.Attribute in element_types: validator = f.getAttributeNameValidator() elif TaurusElementType.Device in element_types: validator = f.getDeviceNameValidator() else: raise KeyError(item) name = validator.getNames(item)[0] return name
def panel_cmd(tango_host, dev, trend): """ Show a TaurusPanel (a Taurus application inspired in Jive and Atk Panel) """ from taurus.qt.qtgui.application import TaurusApplication import sys app = TaurusApplication(cmd_line_parser=None, app_name="tauruspanel") w = TaurusDevPanel() if tango_host is None: from taurus import Factory tango_host = Factory('tango').getAuthority().getFullName() w.setTangoHost(tango_host) if dev is not None: w.setDevice(dev) if trend is True: # TODO: Allow to select TaurusTrend back-end try: from taurus.qt.qtgui.qwt5 import TaurusTrend w.info('Using qwt5 back-end') except: try: from taurus.qt.qtgui.tpg import TaurusTrend w.info('Using tpg back-end') except: TaurusTrend = None w.warning('TaurusTrend widget is not available') if TaurusTrend is not None: plot = TaurusTrend() w.createPanel(plot, 'TaurusTrend', permanent=False) w.show() sys.exit(app.exec_())
def unregisterExtensions(): """Registers the macroserver extensions in the :class:`taurus.core.tango.TangoFactory`""" factory = Factory('tango') factory.unregisterDeviceClass('MacroServer') factory.unregisterDeviceClass('Door')
def _createDeviceObject(self, element_info): # TODO: For Taurus 4 compatibility name = "tango://%s" % element_info.full_name return Factory().getDevice(name)
def _createDeviceObject(self, element_info): return Factory().getDevice(element_info.full_name)
def getNames(self, fullname, factory=None, queryAuth=True): '''reimplemented from :class:`TaurusDeviceNameValidator`. It accepts an extra keyword arg `queryAuth` which, if set to False, will prevent the validator from trying to query a TaurusAuthority to obtain missing info such as the devslashname <--> devalias correspondence. ''' groups = self.getUriGroups(fullname) if groups is None: return None default_authority = None if factory is None: from taurus import Factory factory = Factory(scheme=self.scheme) default_authority = factory.get_default_tango_host() if default_authority is None: import PyTango default_authority = "//" + PyTango.ApiUtil.get_env_var('TANGO_HOST') authority = groups.get('authority') if authority is None: groups['authority'] = authority = default_authority db = None if queryAuth: try: db = factory.getAuthority('tango:%s' % authority) except: pass # note, since we validated, we either have alias or slashname (not # both) _devalias = groups.get('_devalias') _devslashname = groups.get('_devslashname') if _devslashname is None and db is not None: # get _devslashname from the alias using the DB _devslashname = db.getElementFullName(_devalias) groups['_devslashname'] = _devslashname if _devslashname is None: # if we still do not have a slashname, we can only give the short return None, None, _devalias # we can now construct everything. First the complete: complete = 'tango:%(authority)s/%(_devslashname)s' % groups # then the normal if authority.lower() == default_authority.lower(): normal = '%(_devslashname)s' % groups else: normal = '%(authority)s/%(_devslashname)s' % groups # and finally the short if _devalias is not None: short = _devalias else: if db is not None: # get the alias from the DB (if it is defined) short = db.getElementAlias(_devslashname) or _devslashname else: short = _devslashname return complete, normal, short
def getNames(self, fullname, factory=None, queryAuth=True): '''reimplemented from :class:`TaurusDeviceNameValidator`. It accepts an extra keyword arg `queryAuth` which, if set to False, will prevent the validator from trying to query a TaurusAuthority to obtain missing info such as the devslashname <--> devalias correspondence. ''' groups = self.getUriGroups(fullname) if groups is None: return None import PyTango default_authority = '//' + PyTango.ApiUtil.get_env_var('TANGO_HOST') authority = groups.get('authority') if authority is None: groups['authority'] = authority = default_authority db = None if queryAuth: # attempt to get an Authority object if factory is None: from taurus import Factory factory = Factory(scheme=self.scheme) try: db = factory.getAuthority('tango:%s' % authority) except: pass # note, since we validated, we either have alias or slashname (not # both) _devalias = groups.get('_devalias') _devslashname = groups.get('_devslashname') if _devslashname is None and db is not None: # get _devslashname from the alias using the DB _devslashname = db.getElementFullName(_devalias) groups['_devslashname'] = _devslashname if _devslashname is None: # if we still do not have a slashname, we can only give the short return None, None, _devalias # we can now construct everything. First the complete: complete = 'tango:%(authority)s/%(_devslashname)s' % groups # then the normal if authority.lower() == default_authority.lower(): normal = '%(_devslashname)s' % groups else: normal = '%(authority)s/%(_devslashname)s' % groups # and finally the short if _devalias is not None: short = _devalias else: if db is not None: # get the alias from the DB (if it is defined) short = db.getElementAlias(_devslashname) or _devslashname else: short = _devslashname return complete, normal, short