Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(8)  |  Call(4)  |  Derive(0)  |  Import(4)
ApplicationCreated event handler 

        def check_version(ev):
    """ ApplicationCreated event handler """
    if not Version.__table__.exists():
        return

    versions = dict((v.package, v.version_num)
                    for v in ptah.get_session().query(Version).all())
    packages = ptah.get_cfg_storage(MIGRATION_ID).keys()

    has_steps = False
    log = logging.getLogger('ptah.alembic')

    for pkg in packages:
        version = versions.get(pkg)
        script = ScriptDirectory(pkg)
        for sc in script.walk_revisions():
            if sc.is_head:
                if sc.revision != version:
                    has_steps = True
                    log.error("Package '%s' current revision: '%s', head: '%s'",
                              pkg, version, sc.revision)
                break

    if has_steps:
        config.shutdown()
        log.error("Please run `ptah-migrate` script. Stopping...")
        raise SystemExit(1)
        


src/p/t/ptah-0.8.0/ptah/tests/test_migrate.py   ptah(Download)
    def test_startup_check_version(self):
        from ptah.migrate import Version, revision, check_version
 
        ptah.register_migration(
            'test1', 'ptah.tests1:migrations')
        exc = None
        try:
            check_version(None)
        except SystemExit as err: # pragma: no cover
            exc = err
 
        self.assertIsNone(exc)
 
    def test_startup_check_version_exit(self):
        from ptah.migrate import revision, check_version
        exc = None
        try:
            check_version(None)
        except SystemExit as err: # pragma: no cover
            exc = err

src/p/t/ptah-HEAD/ptah/tests/test_migrate.py   ptah(Download)
    def test_startup_check_version(self):
        from ptah.migrate import Version, revision, check_version
 
        ptah.register_migration(
            'test1', 'ptah.tests1:migrations')
        exc = None
        try:
            check_version(None)
        except SystemExit as err: # pragma: no cover
            exc = err
 
        self.assertIsNone(exc)
 
    def test_startup_check_version_exit(self):
        from ptah.migrate import revision, check_version
        exc = None
        try:
            check_version(None)
        except SystemExit as err: # pragma: no cover
            exc = err