コード例 #1
0
ファイル: env.py プロジェクト: adam-iris/kittystore
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    url = context.get_x_argument(as_dictionary=True).get('url')
    if url:
        engine = create_engine(url)
    else:
        engine = engine_from_config(
                    config.get_section(config.config_ini_section),
                    prefix='sqlalchemy.',
                    poolclass=pool.NullPool)

    connection = engine.connect()
    context.configure(
                connection=connection,
                target_metadata=target_metadata
                )

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
コード例 #2
0
ファイル: env.py プロジェクト: tobiashuste/indico
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    engine = engine_from_config(config.get_section(config.config_ini_section),
                                prefix='sqlalchemy.',
                                poolclass=pool.NullPool)

    connection = engine.connect()
    context.configure(connection=connection,
                      target_metadata=target_metadata,
                      include_schemas=True,
                      include_symbol=_include_symbol,
                      render_item=_render_item,
                      version_table=version_table,
                      version_table_schema='public')

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
コード例 #3
0
ファイル: env.py プロジェクト: hanc1208/iu-exchange
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """

    # this callback is used to prevent an auto-migration from being generated
    # when there are no changes to the schema
    # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
    def process_revision_directives(context, revision, directives):
        if getattr(config.cmd_opts, 'autogenerate', False):
            script = directives[0]
            if script.upgrade_ops.is_empty():
                directives[:] = []
                logger.info('No changes in schema detected.')

    engine = engine_from_config(config.get_section(config.config_ini_section),
                                prefix='sqlalchemy.',
                                poolclass=pool.NullPool)

    connection = engine.connect()
    context.configure(connection=connection,
                      target_metadata=target_metadata,
                      process_revision_directives=process_revision_directives)

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
コード例 #4
0
ファイル: __init__.py プロジェクト: outini/dispytch
def info():
    """Get information from dispytch and configured modules

    """
    _log.debug('Get information')
    cur_config = {}
    # get insternal configuration
    for section in _INTERNAL_SECTIONS:
        cur_config.update({ section: config.get_section(section)})
        config.print_section(section)

    # get moludes configuration
    for disp in config.dispatch_list():
        (section, mod_config) = config.get_dispatch(disp)
        cur_config.update({ section: config.get_section(section)})
        config.print_section(section)

    return cur_config
コード例 #5
0
ファイル: __init__.py プロジェクト: outini/dispytch
def dispatch(module_name, args, kwargs):
    """Dispatch request args and kwargs to the selected module

    :param str docpath: Document path called
    :param list args: Positionnal args to pass to the module
    :param dict kwargs: Named args to pass to the module

    :return: Data returned by module
    :rtype: dict
    """
    data = None
    module_config = {}

    # retrieve the required known module using dispatch info from document path
    _log.info("handling new dispatch: {0}".format(module_name))

    # How to handle internal dispatches ?
    #if dispatch_target is not None:
    #    return {'result': dispatch_target()}

    module_config = config.get_section(module_name)
    _log.debug("module config: {0}".format(module_config))

    if not module_config:
        raise ImportError("No module found to handle the request")

    try:
        module = get_module(module_name, config.modules_path)
        module.configure(module_config)
        data = module.handle_request(*args, **kwargs)

    except ImportError:
        raise ImportError("No module found to handle the request")

    except Exception as exc:
        _log.error("handled module error: {0}".format(exc.message))
        raise RuntimeError(exc.message)

    if kwargs.get('mutator'):
        try:
            mutator_name = kwargs['mutator']
            mutator_opts = kwargs.get('mutator_opts')

            _log.debug('selected mutator: {0}'.format(mutator_name))
            mutator = get_mutator(mutator_name)

            _log.debug('sending series to mutator')
            return {'result': mutator(module_name, data[0], data[1],
                                      options=mutator_opts)}

        except ImportError, AttributeError:
            raise ImportError("No mutator found to transform the response")

        except Exception as exc:
            _log.error("handled mutator error: {0}".format(exc.message))
            raise RuntimeError(exc.message)
コード例 #6
0
def run_migrations_online():
    connectable = sqlalchemy.engine_from_config(
        config.get_section(config.config_ini_section),
        prefix="sqlalchemy.",
        poolclass=sqlalchemy.pool.NullPool,
    )

    with connectable.connect() as connection:
        context.configure(connection=connection,
                          target_metadata=target_metadata)

        with context.begin_transaction():
            context.run_migrations()
コード例 #7
0
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    connectable = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix="sqlalchemy.",
        poolclass=pool.NullPool,
    )

    with connectable.connect() as connection:
        context.configure(connection=connection,
                          target_metadata=target_metadata)

        with context.begin_transaction():
            context.run_migrations()
コード例 #8
0
def run_migrations_online() -> None:
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    engine = engine_from_config(config.get_section(config.config_ini_section),
                                prefix="sqlalchemy.",
                                poolclass=pool.NullPool)

    connection = engine.connect()
    configure(connection=connection, target_metadata=target_metadata)

    try:
        with begin_transaction():
            run_migrations()
    finally:
        connection.close()
コード例 #9
0
ファイル: env.py プロジェクト: DirkHoffmann/indico
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    engine = engine_from_config(config.get_section(config.config_ini_section),
                                prefix='sqlalchemy.',
                                poolclass=pool.NullPool)

    connection = engine.connect()
    context.configure(connection=connection, target_metadata=target_metadata, include_schemas=True,
                      version_table_schema='public', include_symbol=_include_symbol, render_item=_render_item)

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
コード例 #10
0
ファイル: env.py プロジェクト: dukov/fuel-external-git
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.
    """
    connectable = sqlalchemy.engine_from_config(
        config.get_section(config.config_ini_section),
        prefix='sqlalchemy.',
        poolclass=sqlalchemy.pool.NullPool,
    )

    with connectable.connect() as connection:
        context.configure(
            connection=connection,
            target_metadata=target_metadata,
            version_table=config.get_main_option('version_table'),
        )

        with context.begin_transaction():
            context.run_migrations()
コード例 #11
0
ファイル: env.py プロジェクト: enixdark/pyra-structures
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    url = config.get_section('db')['url']
    engine = create_engine(url, poolclass=pool.NullPool)

    connection = engine.connect()
    context.configure(
        connection=connection,
        target_metadata=target_metadata,
        transaction_per_migration=True,
    )

    try:
        with context.begin_transaction():
            context.run_migrations()
    finally:
        connection.close()
コード例 #12
0
ファイル: env.py プロジェクト: JoshMayberry/SQLite-Database
def run_migrations_online():
	"""Run migrations in 'online' mode.

	In this scenario we need to create an Engine
	and associate a connection with the context.

	"""
	connectable = sqlalchemy.engine_from_config(
		config.get_section(config.config_ini_section),
		prefix='sqlalchemy.',
		poolclass=sqlalchemy.pool.NullPool)

	with connectable.connect() as connection:
		alembic.context.configure(
			connection = connection,
			target_metadata = target_metadata,
			process_revision_directives = writer,
			render_as_batch = config.get_main_option('sqlalchemy.url').startswith('sqlite:///'),
		)

		with alembic.context.begin_transaction():
			alembic.context.run_migrations()
コード例 #13
0
ファイル: env.py プロジェクト: abrt/faf
def run_migrations_online():
    """Run migrations in 'online' mode.

    In this scenario we need to create an Engine
    and associate a connection with the context.

    """
    engine = engine_from_config(
        config.get_section(config.config_ini_section),
        prefix="sqlalchemy.",
        poolclass=pool.NullPool)

    connection = engine.connect()
    configure(
        connection=connection,
        target_metadata=target_metadata
        )

    try:
        with begin_transaction():
            run_migrations()
    finally:
        connection.close()
コード例 #14
0
ファイル: schongo.py プロジェクト: DarkDNA/Schongo
def main(argv):
	opts, args = getopt.getopt(argv, "v:c", [ "debug", "config=" ])
	print(opts)

	debug = False
	configFile = None

	dn = os.path.dirname(__file__)
	if dn is not "":
		os.chdir(dn)
	del dn

	for arg,val in opts:
		if arg == "--debug" or arg == "-v":
			debug = True
		elif arg == "--config" or arg == "-c":
			configFile = val

	if configFile is None:
		configFile = "data/config-debug.cfg" if debug else "data/config.cfg"

	if not os.path.isfile(configFile):
		if os.path.isfile("data/config.cfg"):
			logging.warn("Config file %s missing, reverting to default" % configFile)
			configFile = "data/config.cfg"
		else:
			logging.error("""We are missing a config file, please look at the example.cfg for help on making a new config, and name it config.cfg or pass a config file using --config

The config file should go in the data directory""")
			return
	

	logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
	#logging.config.fileConfig("logging.cfg")



	config = Config();

	logging.info("Reading config file: %s" % configFile)
	try:
		config.read(configFile)
	except Exception as e:
		logging.error("Error reading config file: %s" % e)
		return

	if debug:
		logging.info("Debug mode activated")

	basic = config.get_section("Basic")

	modules.cfg_basic = basic
	modules.config = config

	modules.init()

	schongos = {}

	for i in basic.getlist("networks"):
		net = config.get_section("Network/%s" % i)
		sch = SchongoClient(i, net)
		"""
			server=net.get("server"),
			port=net.getint("port"),
			)icks=net.getlist("nicks"),
			ident=net.get("ident"),
			realname=net.get("real name"),
			network=i,
			channels=net.getlist("channels")
		)"""
		sch.connect()
		sch.start()
		schongos[i] = sch
	
	modules.connections = schongos

	return schongos
コード例 #15
0
def main(argv):
    opts, args = getopt.getopt(argv, "v:c", ["debug", "config="])
    print(opts)

    debug = False
    configFile = None

    dn = os.path.dirname(__file__)
    if dn is not "":
        os.chdir(dn)
    del dn

    for arg, val in opts:
        if arg == "--debug" or arg == "-v":
            debug = True
        elif arg == "--config" or arg == "-c":
            configFile = val

    if configFile is None:
        configFile = "data/config-debug.cfg" if debug else "data/config.cfg"

    if not os.path.isfile(configFile):
        if os.path.isfile("data/config.cfg"):
            logging.warn("Config file %s missing, reverting to default" %
                         configFile)
            configFile = "data/config.cfg"
        else:
            logging.error(
                """We are missing a config file, please look at the example.cfg for help on making a new config, and name it config.cfg or pass a config file using --config

The config file should go in the data directory""")
            return

    logging.basicConfig(level=(logging.DEBUG if debug else logging.WARN))
    #logging.config.fileConfig("logging.cfg")

    config = Config()

    logging.info("Reading config file: %s" % configFile)
    try:
        config.read(configFile)
    except Exception as e:
        logging.error("Error reading config file: %s" % e)
        return

    if debug:
        logging.info("Debug mode activated")

    basic = config.get_section("Basic")

    modules.cfg_basic = basic
    modules.config = config

    modules.init()

    schongos = {}

    for i in basic.getlist("networks"):
        net = config.get_section("Network/%s" % i)
        sch = SchongoClient(i, net)
        """
			server=net.get("server"),
			port=net.getint("port"),
			nicks=net.getlist("nicks"),
			ident=net.get("ident"),
			realname=net.get("real name"),
			network=i,
			channels=net.getlist("channels")
		)"""
        sch.connect()
        sch.start()
        schongos[i] = sch

    modules.connections = schongos

    return schongos