Example #1
0
def app(request, postgresql):
    app = Flask('test_app')

    class TestConfig():
        DB_URL = postgresql.url()
        TESTING = True
        DEBUG = True
        ADMIN_EMAIL = '*****@*****.**'
        SERVER_NAME = 'test'
        SECRET_KEY = 'secret'
        SOCIAL_AUTH_USER_MODEL = 'matcher.model.User'
        DATA_DIR = 'data'

    app.config.from_object(TestConfig)
    database.init_app(app)

    # Establish an application context before running the tests.
    ctx = app.app_context()
    ctx.push()

    # create database tables
    engine = database.session.get_bind()
    engine.execute('create extension postgis')
    Base.metadata.create_all(engine)

    yield app

    ctx.pop()
Example #2
0
import os.path
import requests.exceptions
import queue
import re
import lxml.etree
import subprocess

from matcher import (wikipedia, database, wikidata_api, netstring, mail,
                     overpass, space_alert, model)
from time import time, sleep
from datetime import datetime
from matcher.place import Place, PlaceMatcher, bbox_chunk
from matcher.view import app

app.config.from_object('config.default')
database.init_app(app)
re_point = re.compile(r'^Point\(([-E0-9.]+) ([-E0-9.]+)\)$')

active_jobs = {}

task_queue = queue.PriorityQueue()


def wait_for_slot(send_queue):
    print('get status')
    try:
        status = overpass.get_status()
    except overpass.OverpassError as e:
        r = e.args[0]
        body = f'URL: {r.url}\n\nresponse:\n{r.text}'
        mail.send_mail('Overpass API unavailable', body)