def minimal_check(schema,
                  interval=3 * 3600,
                  exclude=".*(wavename|waveid)$",
                  csvs=""):
    import re, time
    from PyTangoArchiving import Reader
    from PyTangoArchiving.utils import check_attribute
    r = fun.Struct()
    rd = Reader(schema)
    db = rd.get_database()
    r.ids = db.get_attributes_IDs()
    r.active = db.get_attribute_names(active=True)
    r.shouldbe = get_all_config_attrs(schema, csvs) if csvs else r.active
    r.shouldbe = [a for a in r.shouldbe if not re.match(exclude, a.lower())]
    print('%d attributes are active' % len(r.active))
    print('%d attributes should be active' % len(r.shouldbe))
    r.missing = [a for a in r.shouldbe if a not in r.ids]
    r.polizon = [a for a in r.active if a not in r.shouldbe]
    print('%d attributes are archived but not configured' % len(r.polizon))
    r.updates = db.get_table_updates()
    r.notupdated = [
        a for a in r.active
        if r.updates[db.get_table_name(r.ids[a])] < time.time() - interval
    ]
    print('%d active attributes are not updated' % len(r.notupdated))
    print('%d shouldbe attributes are missing' % len(r.missing))
    r.lost = [
        a for a in r.shouldbe if a in r.ids
        and r.updates[db.get_table_name(r.ids[a])] < time.time() - interval
    ]
    r.lost = filter(check_attribute, r.lost)
    print('%d shouldbe attributes are active but lost' % len(r.lost))
    return r
Exemplo n.º 2
0
def tdb_to_hdb(attribute,start=0,stop=fun.END_OF_TIME,modes={},delete=False):
    """
    This method allows to copy an attribute from TDB to HDB, inserting the contents
    of the current TDB buffer into the HDB tables.
    @param start/stop allow to limit the dates for insertion
    @param delete will remove all existing values in HDB for the given interval
    """
    from PyTangoArchiving import Reader
    hdb,tdb = Reader('hdb'),Reader('tdb')
    assert attribute in tdb.get_attributes()
    values = tdb.get_attribute_values(attribute,start or time.time()-tdb.RetentionPeriod,stop)
    if attribute not in hdb.get_attributes(): 
        from PyTangoArchiving import ArchivingAPI
        api = ArchivingAPI('hdb')
        api.start_archiving(*((attribute,modes) if modes else (attribute,)))
        api.load_attribute_descriptions()
    db = hdb.get_database()
    table = db.get_table_name(db.get_attribute_ID(attribute))
    import_into_db(db,table,values,delete)    
Exemplo n.º 3
0
def tdb_to_hdb(attribute,start=0,stop=fun.END_OF_TIME,modes={},delete=False):
    """
    This method allows to copy an attribute from TDB to HDB, inserting the contents
    of the current TDB buffer into the HDB tables.
    @param start/stop allow to limit the dates for insertion
    @param delete will remove all existing values in HDB for the given interval
    """
    from PyTangoArchiving import Reader
    hdb,tdb = Reader('hdb'),Reader('tdb')
    assert attribute in tdb.get_attributes()
    values = tdb.get_attribute_values(attribute,start or time.time()-tdb.RetentionPeriod,stop)
    if attribute not in hdb.get_attributes(): 
        from PyTangoArchiving import ArchivingAPI
        api = ArchivingAPI('hdb')
        api.start_archiving(*((attribute,modes) if modes else (attribute,)))
        api.load_attribute_descriptions()
    db = hdb.get_database()
    table = db.get_table_name(db.get_attribute_ID(attribute))
    import_into_db(db,table,values,delete)    
def minimal_check(schema,interval=3*3600,exclude=".*(wavename|waveid)$",csvs=""):
    import re,time
    from PyTangoArchiving import Reader
    from PyTangoArchiving.utils import check_attribute
    r = fun.Struct()
    rd = Reader(schema)
    db = rd.get_database()
    r.ids = db.get_attributes_IDs()
    r.active = db.get_attribute_names(active=True)
    r.shouldbe = get_all_config_attrs(schema,csvs) if csvs else r.active
    r.shouldbe = [a for a in r.shouldbe if not re.match(exclude,a.lower())]
    print('%d attributes are active'%len(r.active))
    print('%d attributes should be active'%len(r.shouldbe))
    r.missing = [a for a in r.shouldbe if a not in r.ids]
    r.polizon = [a for a in r.active if a not in r.shouldbe]
    print('%d attributes are archived but not configured'%len(r.polizon))
    r.updates = db.get_table_updates()
    r.notupdated = [a for a in r.active if  r.updates[db.get_table_name(r.ids[a])]<time.time()-interval]
    print('%d active attributes are not updated'%len(r.notupdated))
    print('%d shouldbe attributes are missing'%len(r.missing))    
    r.lost = [a for a in r.shouldbe if a in r.ids and r.updates[db.get_table_name(r.ids[a])]<time.time()-interval]
    r.lost = filter(check_attribute,r.lost)
    print('%d shouldbe attributes are active but lost'%len(r.lost))
    return r