示例#1
0
def test():
    
    log.debug('Testing replica_db')
    from gateway import Gateway
    g = Gateway('http://albedo2.dkrz.de/esgcet')
    files = g.listFiles('cmip5.output1.MPI-M.MPI-ESM-LR.historical.mon.seaIce.OImon.r1i1p1')

    import re
    db = ReplicaDB('sqlite:///:memory:')
    #db = ReplicaDB('sqlite:///replica.db')
    print "File metadata:"
    print files[0]
    inserted = []
    rejected = []
    files_o = db.add_all(files, inserted=inserted, rejected=rejected, update=True) #, overwrite=True)
    log.debug('Ins: %s, rej: %s', len(inserted), len(rejected) )

    print "File"
    print files_o[0]

    print "Query something..."
    f_dao = None
    for row in db.get():
        if not f_dao: f_dao = row
        print row.path[:20], "...", row.name, len(row.endpoints), [ ep.name for ep in row.endpoints]
    db.close()


    print f_dao.getDRS().getId(), f_dao.getDRS().getDirectory(), f_dao.getDRS().getFilename()
    print f_dao.getMapFileEntry('/My_root_dir/')
    return locals()
示例#2
0
def __getGatewayFiles(dataset):
    from gateway import Gateway
    gateway = 'cmip-gw.badc.rl.ac.uk'
    log.debug('Contacting remote Gateway: %s', gateway)
    g = Gateway('http://' + gateway)
    
    log.debug('getting files from %s', dataset)


    files = g.listFiles(dataset)

    if not files: raise Exception("No file found! Probably the test is outdated....")
    return files