Ejemplo n.º 1
0
def create_app(env='Defaults'):
    """
    Creates application.
    :returns: flask application instance
    """
    app = Flask(__name__)
    cfgfile = os.environ.get('BUILDING_SETTINGS')
    if cfgfile:
        app.config.update(load_yaml_config(cfgfile))
    else:
        try:
            cfgfile = (Path(__file__).parent / '..' / 'conf' / 'building.yml').resolve()
        except FileNotFoundError:
            logger.warning('no config file found !!')
            sys.exit(1)
    app.config.update(load_yaml_config(str(cfgfile)))
    print(str(cfgfile))
    set_level(app.config['LOG_LEVEL'])
    logger.debug('loading config from {}'.format(cfgfile))

    # load extensions
    if 'URL_PREFIX' in app.config:
        blueprint = Blueprint('api', __name__, url_prefix=app.config['URL_PREFIX'])
    else:
        blueprint = Blueprint('api', __name__)

    api.init_app(blueprint)
    app.register_blueprint(blueprint)
    Session.init_app(app)
    CitiesConfig.init(str(cfgfile))

    return app
Ejemplo n.º 2
0
def create_app(env='Defaults'):
    """
    Creates application.
    :returns: flask application instance
    """
    app = Flask(__name__)
    cfgfile = os.environ.get('BUILDING_SETTINGS')
    if cfgfile:
        app.config.update(load_yaml_config(cfgfile))
    else:
        try:
            cfgfile = (Path(__file__).parent / '..' / 'conf' /
                       'building.yml').resolve()
        except FileNotFoundError:
            logger.warning('no config file found !!')
            sys.exit(1)
    app.config.update(load_yaml_config(str(cfgfile)))
    print(str(cfgfile))
    set_level(app.config['LOG_LEVEL'])
    logger.debug('loading config from {}'.format(cfgfile))

    # load extensions
    if 'URL_PREFIX' in app.config:
        blueprint = Blueprint('api',
                              __name__,
                              url_prefix=app.config['URL_PREFIX'])
    else:
        blueprint = Blueprint('api', __name__)

    api.init_app(blueprint)
    app.register_blueprint(blueprint)
    Session.init_app(app)
    CitiesConfig.init(str(cfgfile))

    return app
Ejemplo n.º 3
0
    def setUp(self):
        # init mock session
        cfgfile = "{0}/testcfg.yml".format(os.path.dirname(os.path.abspath(__file__)))
        CitiesConfig.init(cfgfile)

        self.mockSession = MockSession()
        Session.offset = self.mockSession.offset
        Session.tile_geom_geojson = self.mockSession.tile_geom_geojson
        Session.bbox_for_quadtiles = self.mockSession.bbox_for_quadtiles
        Session.attribute_for_gid = self.mockSession.attribute_for_gid

        # build args
        self.args = {}
        self.args["city"] = "montreal"
        self.args["tile"] = "6/22/28"
        self.args["attributes"] = ""
Ejemplo n.º 4
0
    def setUp(self):
        # init mock session
        cfgfile = ("{0}/testcfg.yml".format(
            os.path.dirname(os.path.abspath(__file__))))
        CitiesConfig.init(cfgfile)

        self.mockSession = MockSession()
        Session.offset = self.mockSession.offset
        Session.tile_geom_geojson = self.mockSession.tile_geom_geojson
        Session.bbox_for_quadtiles = self.mockSession.bbox_for_quadtiles
        Session.attribute_for_gid = self.mockSession.attribute_for_gid

        # build args
        self.args = {}
        self.args['city'] = "montreal"
        self.args['tile'] = "6/22/28"
        self.args['attributes'] = ""
Ejemplo n.º 5
0
 def setUp(self):
     cfgfile = ("{0}/testcfg.yml"
                .format(os.path.dirname(os.path.abspath(__file__))))
     CitiesConfig.init(cfgfile)