def run_master(): # pragma: no cover """Runs :func:`load_master` then runs the application""" from pyfarm.master.application import app, api parser = ArgumentParser() if app.debug: parser.add_argument("--drop-all", "-D", action="store_true", help="drop the existing tables before starting") parser.add_argument("--create-all", "-C", action="store_true", help="create all tables before starting") parser.add_argument("--confirm-drop") parser.add_argument("--allow-agent-loopback-addresses", action="store_true") parsed = parser.parse_args() if app.debug and parsed.drop_all: db.drop_all() if parsed.allow_agent_loopback_addresses: config["allow_agents_from_loopback"] = True if parsed.create_all: db.create_all() load_setup(app) load_master(app, api) app.run(host=config.get("flask_listen_address"), debug=config.get("debug"))
def run_master(): # pragma: no cover """Runs :func:`load_master` then runs the application""" from pyfarm.master.application import app, api parser = ArgumentParser() if app.debug: parser.add_argument("--drop-all", "-D", action="store_true", help="drop the existing tables before starting") parser.add_argument("--create-all", "-C", action="store_true", help="create all tables before starting") parser.add_argument("--confirm-drop") parser.add_argument("--allow-agent-loopback-addresses", action="store_true") parsed = parser.parse_args() if app.debug and parsed.drop_all: db.drop_all() if parsed.allow_agent_loopback_addresses: config["allow_agents_from_loopback"] = True if parsed.create_all: db.create_all() load_setup(app) load_master(app, api) app.run( host=config.get("flask_listen_address"), debug=config.get("debug") )
def create_app(): """An entry point specifically for uWSGI or similar to use""" from pyfarm.master.application import app, api if config.get("dev_db_drop_all"): db.drop_all() if config.get("dev_db_create_all"): db.create_all() load_setup(app) load_master(app, api) return app
def tables(): # pragma: no cover """ Small script for basic table management and, eventually, some introspection as well. """ parser = ArgumentParser(description="Creates PyFarm's tables") parser.add_argument( "--echo", action="store_true", help="If provided then echo the SQL queries being made") parser.add_argument( "--drop-all", action="store_true", help="If provided all tables will be dropped from the database " "before they are created.") parser.add_argument("--no-create-tables", action="store_true", help="If provided then no tables will be created.") args = parser.parse_args() db.engine.echo = args.echo if db.engine.name == "sqlite" and db.engine.url.database == ":memory:": logger.info("Nothing to do, in memory sqlite database is being used") return if args.drop_all: db.drop_all() if not args.no_create_tables: try: db.create_all() except Exception as e: logger.error( "Failed to call create_all(). This may be an error or " "it may be something that can be ignored: %r", e) else: logger.info("Tables created or updated")
def tables(): # pragma: no cover """ Small script for basic table management and, eventually, some introspection as well. """ parser = ArgumentParser( description="Creates PyFarm's tables") parser.add_argument( "--echo", action="store_true", help="If provided then echo the SQL queries being made") parser.add_argument( "--drop-all", action="store_true", help="If provided all tables will be dropped from the database " "before they are created.") parser.add_argument( "--no-create-tables", action="store_true", help="If provided then no tables will be created.") args = parser.parse_args() db.engine.echo = args.echo if db.engine.name == "sqlite" and db.engine.url.database == ":memory:": logger.info("Nothing to do, in memory sqlite database is being used") return if args.drop_all: db.drop_all() if not args.no_create_tables: try: db.create_all() except Exception as e: logger.error( "Failed to call create_all(). This may be an error or " "it may be something that can be ignored: %r", e) else: logger.info("Tables created or updated")
def teardown_database(self): db.session.remove() db.drop_all()
def tearDown(self): db.session.remove() db.drop_all()