Ejemplo n.º 1
0
def test_load():
    begin = time.time()
    #import variable
    #variable.all()
    import soap
    #print soap.get_statistic('11111')
    #soap.get_statistic('183')
    #logging.info(soap.get_table_meta('11111-0001'))
    #soap.get_variable('ERW006')
    import statistic
    #statistic.all()
    #statistic.get('11111')
    #statistic.get('43311')
    #statistic.get('52311')
    #print soap.get_variable('ADSST2', var_name='code')
    pprint(soap.find_tables_by_statistic('11111'))
    
    import table
    #pprint(table.get('12211-0007'))
    #table.get('21411-0001', force_reload=True)
    #table.get('43311-0001', force_reload=True)
    #table.get('12211-0104', force_reload=True)
    
    #logging.info(table.get('12211-0104', force_reload=True))
    
    #run_once()
    print "TIME: %s" % (time.time() - begin)
Ejemplo n.º 2
0
def test_load():
    begin = time.time()
    #import variable
    #variable.all()
    import soap
    #print soap.get_statistic('11111')
    #soap.get_statistic('183')
    #logging.info(soap.get_table_meta('11111-0001'))
    #soap.get_variable('ERW006')
    import statistic
    #statistic.all()
    #statistic.get('11111')
    #statistic.get('43311')
    #statistic.get('52311')
    #print soap.get_variable('ADSST2', var_name='code')
    pprint(soap.find_tables_by_statistic('11111'))

    import table
    #pprint(table.get('12211-0007'))
    #table.get('21411-0001', force_reload=True)
    #table.get('43311-0001', force_reload=True)
    #table.get('12211-0104', force_reload=True)

    #logging.info(table.get('12211-0104', force_reload=True))

    #run_once()
    print "TIME: %s" % (time.time() - begin)
Ejemplo n.º 3
0
def get(stat_id, include_tables=True):
    db = mongo.get_db()
    statistic = db.statistics.find_one({'code': stat_id})
    if (not statistic) or config.bool('reload'):
        logging.info("Statistic %s not found, loading from SOAP...", stat_id)
        statistic = soap.get_statistic(stat_id)
        if not statistic: 
            return None
        tables = []
        for table in soap.find_tables_by_statistic(stat_id):
            tables.append(table)
        statistic['tables'] = tables
        statistic['description'] = load_description(stat_id)
        statistic['variables'] = [v for v in load_variables(stat_id)]
        statistic['__ts'] = datetime.utcnow()
        db.statistics.update({'code': stat_id}, statistic, upsert=True)
    import table
    for _table in statistic['tables']:
        table.get(_table.get('code'))
    return statistic