예제 #1
0
def get_hdbpp_databases(active=True):  #archivers=[],dbs={}):
    """
    Method to obtain list of dbs/archivers; it allows to match any 
    archiver list against existing dbs.
    
    This method can be used in cached mode executed like:
    
        dbs = get_hdbpp_databases()
        for a in archivers:
            db = get_hdbpp_databases(a,dbs).keys()[0]
      
    """
    schemas = pta.Schemas.load()
    hdbpp = sorted(k for k in schemas if fn.clsearch('hdbpp', str(schemas[k])))
    if active:
        r = []
        for h in hdbpp:
            try:
                if fn.check_device(pta.api(h).manager):
                    r.append(h)
            except:
                pass
        return r
    else:
        return hdbpp
예제 #2
0
파일: panel.py 프로젝트: MikeFalowski/VACCA
 def apply_search(self):
     signs = "==|=|<|>"
     txt = str(self.search.text() or '*')
     if fandango.clsearch(signs, txt):
         t = fandango.re.split(signs, txt, 1)[0]
         txt, formula = t, txt.replace(t, '')
     else:
         formula = ''
     txt = txt.replace(' ', '*').strip()
     txt = self.preffix + txt + self.suffix
     model = fandango.get_matching_attributes(txt)
     if self.labels and '/' in txt:
         dev, attr = txt.rsplit('/', 1)
         model.extend(
             fandango.tango.get_matching_device_attribute_labels(
                 dev, attr).keys())
     if formula and model:
         nm = []
         for m in model:
             try:
                 f = '%s %s' % (fandango.read_attribute(m), formula)
                 if eval(f):
                     nm.append(m)
             except:
                 pass
         model = nm
     self.form.setModel(model)
예제 #3
0
 def get_partition_time_by_name(self, partition):
     m = fn.clsearch('[0-9].*', partition)
     if m:
         d = fn.str2time(m.group(), cad='%Y%m%d')
         return d
     else:
         return fn.END_OF_TIME
예제 #4
0
 def get_all_databases(regexp='*'):
     """
     Return all registered HDB++ databases
     """
     managers = HDBpp.get_all_managers()
     dbs = [HDBpp.get_db_config(m) for m in managers]
     dbs = [d for d in dbs if fn.clsearch(regexp, str(d))]
     return [t[0] for t in dbs]
예제 #5
0
 def get_all_databases(regexp='*'):
     """
     Return all registered HDB++ databases
     """
     managers = HDBpp.get_all_managers()
     dbs = [HDBpp.get_db_config(m) for m in managers]
     dbs = [d for d in dbs if fn.clsearch(regexp,str(d))]
     return [t[0] for t in dbs]
예제 #6
0
 def get_archived_attributes(self, search=''):
     #print('get_archived_attributes(%s)'%str(search))
     attrs = []
     archs = get_device_property(self.manager, 'ArchiverList')
     #self.get_manager().ArchiverList
     self.get_archivers_attributes(archs, full=False, from_db=False)
     for d, dattrs in self.dedicated.items():
         for a in dattrs:
             self.attributes[a].archiver = d
             if not search or fn.clsearch(search, a):
                 attrs.append(a)
     return attrs
예제 #7
0
 def get_attribute_indexes(self, table):
     index = None
     if fn.isSequence(table):
         aid, tid, table = table
     else:
         if '[' in table:
             try:
                 index = int(fn.clsearch('\[([0-9]+)\]', table).groups()[0])
                 table = table.split('[')[0]
             except:
                 pass
         aid, tid, table = self.get_attr_id_type_table(table)
     return aid, tid, table, index
예제 #8
0
 def get_archived_attributes(self,search=''):
     """
     It gets attributes currently assigned to archiver and updates
     internal attribute/archiver index.
     
     DONT USE Manager.AttributeSearch, it is limited to 1024 attrs!
     """
     #print('get_archived_attributes(%s)'%str(search))
     attrs = []
     [self.get_archiver_attributes(d,from_db=True) 
         for d in self.get_archivers()]
     for d,dattrs in self.dedicated.items():
         for a in dattrs:
             self.attributes[a].archiver = d
             if not search or fn.clsearch(search,a):
                 attrs.append(a)
     return attrs        
예제 #9
0
 def get_subscribed_attributes(self, search=''):
     """
     It gets attributes currently assigned to subscribers and updates
     internal attribute/archiver index.
     
     DONT USE Manager.AttributeSearch, it is limited to 1024 attrs!
     """
     #print('get_archived_attributes(%s)'%str(search))
     attrs = []
     self.get_att_conf_table()
     [
         self.get_archiver_attributes(d, from_db=True)
         for d in self.get_subscribers()
     ]
     for d, dattrs in self.dedicated.items():
         for a in dattrs:
             if a not in self.attributes:
                 self.get_attr_id_type_table(a)
             self.attributes[a].archiver = d
             if not search or fn.clsearch(search, a):
                 attrs.append(a)
     return attrs