示例#1
0
文件: imp0rt.py 项目: jmimo/dabsa
    def dispatch_request(self):

        logger = dlog.get_logger('imp0rt')

        if request.method == 'POST':
            importfile = request.files['airspace']
            if importfile:
                logger.info('parsing file')
                airspaceFile = parse(importfile.filename,importfile)
                logger.info('file parsed')
                try:
                    db.add(airspaceFile)
                    logger.info('added airspaces to database')
                    db.commit()
                    logger.info('commited data')
                except Exception as e:
                    logger.error(e.message)
                    logger.info(e)
                    raise

        model = self.get_objects()
        model['files'] = AirspaceFile.query.all()
        return self.render_template(model)
示例#2
0
文件: mq.py 项目: PyWilhelm/EDRIS_DS
from edris_server import dbm
from edris_server.conf import conf
import dlog
import functools
import json
import md5


sync_lock = Lock()

# FIXME: MAX_NUMBER_PROCESSING
MAX_PROCESSING_TIMEOUT = conf.schedule_conf['taskTimeout']
MAX_PROCESSING_AMOUNT = conf.schedule_conf['maxWaitingTask']
MAX_LOAD_AMOUNT = conf.schedule_conf['maxWaitingTask']

logger = dlog.get_logger(__name__)


def threaded_safe(function):
    @functools.wraps(function)
    def wrapper(*args, **kw):
        sync_lock.acquire()
        try:
            result = function(*args, **kw)
        except Expection as err:
            raise err
        finally:
            sync_lock.release()
        return result
    return wrapper
示例#3
0
文件: openair.py 项目: jmimo/dabsa
    'GP':'GLIDER_PROHIBITED',
    'CTR':'CTR',
    'W':'WAVE_WINDOW',
    'FF':'FLYING_FIELD',
    'HP':'HELIPORT',
    'BB':'CABLECAR',
    'BC':'CABLE',
    'HI':'OBSTACLE',
    'GG':'LOCAL_DANGERZONE',
    'SZ':'WILDLIFE_PROTECTION',
    'VZ':'FLIGHT_PROHIBITED'
}

AIRSPACE_CLASSES_REF = dict((v,k) for k,v in AIRSPACE_CLASSES.iteritems())

logger = dlog.get_logger('openair-parser')

def parse(filename,filepointer):
    rows = filepointer.readlines()
    airspaceFile = AirspaceFile(name=filename, importDate=datetime.now())
    counter = 0
    previousLine = ''
    for line in rows:
	#logger.debug(line)
        identifier = line[:2]
        bareline = line[3:].replace('\r\n','')
        if(re.match("^[A-Za-z]",identifier)):
            if identifier == 'AC':
                airspace = Airspace(type=AIRSPACE_CLASSES[bareline],description=previousLine[14:].replace('\r\n',''))
                airspaceFile.airspaces.append(airspace)
                counter = 0
示例#4
0
文件: ajax.py 项目: jmimo/dabsa
from web import app
from database import db
import shapely.geometry
from numpy import array
from model import Airspace, Point
from flask import request, render_template
import dlog

logger = dlog.get_logger('ajax-controller')

@app.route('/ajax/selectionmenu', methods=['GET'])
def ajax_selection_menu():
    return render_template('selection_menu.html')

@app.route('/ajax/shapemenu', methods=['GET'])
def ajax_shape_menu():
    return render_template('shape_menu.html')

@app.route('/ajax/staticmenu', methods=['GET'])
def ajax_static_menu():
    return render_template('static_menu.html')

@app.route('/ajax/selection/<qualifier>', methods=['POST'])
def ajax_evaluate(qualifier):
    size = int(request.form['size'])
    points = []
    formpoint = None
    counter = 0
    while counter < size:
        formpoint = request.form['point_' + str(counter)]
        if not formpoint:
示例#5
0
文件: database.py 项目: jmimo/dabsa
import config
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
from sqlalchemy.ext.declarative import declarative_base
import dlog

logger = dlog.get_logger('database')
logger.info(config.SQLALCHEMY_DATABASE_URI)

dbengine = create_engine(config.SQLALCHEMY_DATABASE_URI, convert_unicode=True, echo=True)

db_engine_logger = dlog.get_logger('sqlalchemy.engine')
db_orm_logger = dlog.get_logger('sqlalchemy.orm')
db_pool_logger = dlog.get_logger('sqlalchemy.pool')
db_dialect_logger = dlog.get_logger('sqlalchemy.dialects')

db = scoped_session(sessionmaker(autocommit=False,autoflush=True,bind=dbengine))

Base = declarative_base()
Base.query = db.query_property()

def init_db():
    import model
    Base.metadata.create_all(bind=dbengine)

def shutdown_db(exception=False):
    db.remove()