Ignore:
Timestamp:
Apr 26, 2020, 5:02:25 PM (7 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
debian/bullseye, master
Children:
62569d9
Parents:
691c4ca
Message:
  • Adapted code_generator to
    • handle several packages
    • to configure the port from yaml specification
    • to use the VERSION used by setup.py
  • Added deviceservice.yaml with first version of webservice
  • Moved Config loader and HttpErrors to gnuboat.common
  • Moved rrd archive schema to gnuboat.common.device
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/gnuboat/mapservice_impl/controllers/LogsController.py

    r691c4ca rf9321aa  
    2121    Water, Device, Gauge, ProcessingStatus, Queue, db
    2222)
    23 from gnuboat.mapservice_impl.HttpErrors import (
    24     MapserviceBadRequest, MapserviceUnauthorized, MapserviceNotFound
     23from gnuboat.common.webservice.HttpErrors import (
     24    GnuboatBadRequest, GnuboatUnauthorized, GnuboatNotFound
    2525)
    2626from gnuboat.mapservice_impl.tasks.tasks import log_process
    … …  
    3333        submitter = User.query.filter_by(username=submitter).all()
    3434        if len(submitter) != 1:
    35             raise MapserviceNotFound(
     35            raise GnuboatNotFound(
    3636                detail="Could not find the submitter with id {}".
    3737                format(submitter)
    … …  
    5555    log = Log.query.filter_by(id=id).all()
    5656    if len(log) != 1:
    57         raise MapserviceNotFound
     57        raise GnuboatNotFound
    5858    if connexion.request.headers['Accept'] == "application/geo+json":
    5959        return log[0].to_geojson(), 200, {
    … …  
    6666    user = User.loggedin_user()
    6767    if user is None:
    68         raise MapserviceUnauthorized
     68        raise GnuboatUnauthorized
    6969
    7070    water = Water.query.filter_by(id=log_creation.water).all()
    7171    if len(water) != 1:
    72         raise MapserviceBadRequest(
     72        raise GnuboatBadRequest(
    7373            detail='Water {} not found database'.format(log_creation.water)
    7474        )
    … …  
    7777    device = Device.query.filter_by(id=log_creation.device).all()
    7878    if len(device) != 1:
    79         raise MapserviceBadRequest(
     79        raise GnuboatBadRequest(
    8080            detail='Device {} not found in database'.
    8181            format(log_creation.device)
    … …  
    8585    gauge = Gauge.query.filter_by(id=log_creation.gauge).all()
    8686    if len(gauge) != 1:
    87         raise MapserviceBadRequest(
     87        raise GnuboatBadRequest(
    8888            detail='Gauge {} not found in database'.format(log_creation.gauge)
    8989        )
    … …  
    9191
    9292    if log_creation.gauge_height is None:
    93         raise MapserviceBadRequest(detail='Gauge Height (Stage) missing')
     93        raise GnuboatBadRequest(detail='Gauge Height (Stage) missing')
    9494    else:
    9595        try:
    9696            float(log_creation.gauge_height)
    9797        except ValueError:
    98             raise MapserviceBadRequest(
     98            raise GnuboatBadRequest(
    9999                detail='Gauge Height (Stage) {} is no number'.
    100100                format(log_creation.gauge_height)
    … …  
    122122    user = User.loggedin_user()
    123123    if user is None:
    124         raise MapserviceUnauthorized
     124        raise GnuboatUnauthorized
    125125
    126126    if body is None or not body:
    127         raise MapserviceBadRequest(detail='No log data')
     127        raise GnuboatBadRequest(detail='No log data')
    128128
    129129    processing_state = ProcessingStatus.query.filter_by(
    … …  
    131131    ).all()
    132132    if len(processing_state) != 1:
    133         raise MapserviceBadRequest(
     133        raise GnuboatBadRequest(
    134134            detail='Processing status Queued for Parsing not found database'
    135135        )
    … …  
    138138    log = Log.query.filter_by(id=log_id).all()
    139139    if len(log) != 1:
    140         raise MapserviceBadRequest(
     140        raise GnuboatBadRequest(
    141141            detail='Log {} not found database'.format(log_id)
    142142        )
    … …  
    145145    # check if Log has already log entries
    146146    if LogEntry.query.filter_by(log=log).count() > 0:
    147         raise MapserviceBadRequest(
     147        raise GnuboatBadRequest(
    148148            detail='Log {} has already log entries. Aborting'.format(log_id)
    149149        )
    … …  
    164164    user = User.loggedin_user()
    165165    if user is None:
    166         raise MapserviceUnauthorized
     166        raise GnuboatUnauthorized
    167167
    168168    if not Log.query.filter_by(submitter=user).filter_by(id=id).delete():
    169         raise MapserviceBadRequest(
     169        raise GnuboatBadRequest(
    170170            detail="Could not delete log with id {}".format(id)
    171171        )
Note: See TracChangeset for help on using the changeset viewer.