Exemple #1
0
def init_database(dbid, dataset='minimal', autocommit=False):
    bootstrap_path = pkg.resource_filename('antioch.core.bootstrap', '%s.py' % dataset)
    
    bootstrap.load_python(connection, bootstrap_path)
    bootstrap.initialize_plugins(connection)

    return connection
Exemple #2
0
def init_database(dbid, dataset='minimal', autocommit=False):
    bootstrap_path = pkg.resource_filename('antioch.core.bootstrap',
                                           '%s.py' % dataset)

    bootstrap.load_python(connection, bootstrap_path)
    bootstrap.initialize_plugins(connection)

    return connection
Exemple #3
0
 def handle(self, bootstrap='default', *args, **config):
     if(bootstrap in builtin_templates):
         bootstrap_path = pkg.resource_filename('antioch.core.bootstrap', '%s.py' % bootstrap)
     else:
         bootstrap_path = bootstrap
     load_python(connection, bootstrap_path)
     initialize_plugins(connection)
     
Exemple #4
0
 def handle(self, bootstrap='default', *args, **config):
     if (bootstrap in builtin_templates):
         bootstrap_path = pkg.resource_filename('antioch.core.bootstrap',
                                                '%s.py' % bootstrap)
     else:
         bootstrap_path = bootstrap
     load_python(connection, bootstrap_path)
     initialize_plugins(connection)
Exemple #5
0
 def handle(self, template='default', *args, **config):
     if(template in builtin_templates):
         bootstrap_path = pkg.resource_filename('antioch.core.bootstrap', '%s.py' % template)
     else:
         bootstrap_path = template
     pool = dbapi.connect(settings.DB_URL)
     bootstrap.load_python(pool, bootstrap_path)
     bootstrap.initialize_plugins(pool)
     
Exemple #6
0
def init_database(dbid, dataset='minimal', autocommit=False):
    global pool
    if(dbid not in pool and len(pool) == 1):
        key, p = pool.items()[0]
        p.close()
        del pool[key]
    elif(dbid in pool):
        return pool[dbid]
    
    db_url = settings.DB_URL_TEST
    
    bootstrap.initialize_database(psql_path, db_url)
    
    schema_path = pkg.resource_filename('antioch.core.bootstrap', 'schema.sql')
    bootstrap.load_schema(psql_path, db_url, schema_path)
    
    pool[dbid] = dbapi.connect(db_url, **dict(
        autocommit        = autocommit,
    ))
    bootstrap_path = pkg.resource_filename('antioch.core.bootstrap', '%s.py' % dataset)
    bootstrap.load_python(pool[dbid], bootstrap_path)

    return pool[dbid]
Exemple #7
0
    except usage.UsageError, e:
        print config.getSynopsis()
        print config.getUsage()
        print e.args[0]
        sys.exit(1)

    if(config['schema-file']):
        schema_path = config['schema-file']
    else:
        schema_path = pkg.resource_filename('antioch.core.bootstrap', default_schema_path)
    schema_path = os.path.abspath(schema_path)

    if(config['bootstrap-file']):
        bootstrap_path = config['bootstrap-file']
    else:
        bootstrap_path = pkg.resource_filename('antioch.core.bootstrap', default_bootstrap_path % config['dataset-name'])
    bootstrap_path = os.path.abspath(bootstrap_path)
    
    if not(config['no-init']):
        bootstrap.initialize_database(config['with-psql'], config['db-url'], config['psql-args'], quiet=False)
    
    from django.core.management import call_command
    call_command('syncdb', interactive=False)
    call_command('migrate', interactive=False)
    
    pool = dbapi.connect(config['db-url'])
    bootstrap.load_python(pool, bootstrap_path)
    bootstrap.initialize_plugins(pool)

if(__name__ == '__main__'):
    main()