Exemple #1
0
from odpw.utils.utils_snapshot import getPreviousWeek
from odpw.web_rest.rest.odpw_restapi import api
from odpw.core.db import row2dict
from odpw.core.model import Portal, PortalSnapshotQuality, PortalSnapshot, ResourceInfo, MetaResource, Dataset, \
    DatasetData, DatasetQuality

import logging

from flask import request
from flask_restplus import Resource

from schemadotorg import dcat_to_schemadotorg

log = logging.getLogger(__name__)

ns = api.namespace('portal', description='Operations related to a specific portal')

@ns.route('/<portalid>/<int:snapshot>/all')
@ns.doc(params={'portalid': 'A portal id', 'snapshot':'Snapshot in yyww format (e.g. 1639 -> 2016 week 39)'}, description="This API returns the portal specific information and the aggregated quality measures for a given portal and snapshot")
class PortalAll(Resource):
    def get(self, portalid,snapshot):
        q=PortalSnapshot.query
        if snapshot is not None:
            q=q.filter(PortalSnapshotQuality.snapshot==snapshot)
        q=q.filter(PortalSnapshot.portalid==portalid)\
            .outerjoin(PortalSnapshotQuality, and_(PortalSnapshot.portalid==PortalSnapshotQuality.portalid,PortalSnapshot.snapshot==PortalSnapshotQuality.snapshot))\
            .join(Portal)\
            .add_entity(PortalSnapshotQuality)\
            .add_entity(Portal)

        return jsonify([row2dict(i) for i in q.all()])
from odpw.core.model import Portal, PortalSnapshotQuality, PortalSnapshot, ResourceInfo, MetaResource, Dataset, \
    DatasetData, DatasetQuality


from flask import request
from flask_restplus import Resource, fields
from schemadotorg import dcat_to_schemadotorg

from email.utils import formatdate
import email.utils as eut
from time import mktime

import logging
log = logging.getLogger(__name__)

ns = api.namespace('memento', description='Operations to retrieve historical dataset information')
HOST = 'http://data.wu.ac.at/portalwatch/api/v1/memento'

def add_memento_header(resp, orig_ref, timegate, snapshot):
    # timestamp of snapshot
    dt = tofirstdayinisoweek(snapshot)
    stamp = mktime(dt.timetuple())
    formatted_dt = formatdate(
        timeval=stamp,
        localtime=False,
        usegmt=True
    )
    resp.headers['Memento-Datetime'] = formatted_dt
    # link to original resource
    resp.headers['Link'] = orig_ref + '; rel="original", ' + timegate + '; rel="timegate"'
    return resp
Exemple #3
0
import logging

from flask import current_app, Response, jsonify

from odpw.web_rest.rest.odpw_restapi import api
from odpw.web_rest.rest.helpers import toJSON, toCSV
from odpw.core.db import row2dict
from odpw.core.model import Portal, PortalSnapshotQuality, PortalSnapshot, ResourceInfo, Base
from odpw.web_rest.cache import cache

from flask_restplus import Resource

log = logging.getLogger(__name__)

ns = api.namespace(
    'portals',
    description='Operations related to the set of all portals in the system')
from flask import request
from flask_restplus import Resource

from flask_restplus import reqparse

pagination_arguments = reqparse.RequestParser()
pagination_arguments.add_argument('page',
                                  type=int,
                                  required=False,
                                  default=1,
                                  help='Page number')
pagination_arguments.add_argument('bool',
                                  type=bool,
                                  required=False,
import os

import functools

from flask import after_this_request
from odpw.core.model import ResourceCrawlLog
from flask import request
from flask import send_file
from flask import url_for
from flask_restplus import Resource
from odpw.web_rest.rest.odpw_restapi import api
from odpw.utils.datamonitor_utils import parseDate

log = logging.getLogger(__name__)

ns = api.namespace('data', description='Operations related to blog categories')

from flask import Blueprint, current_app, render_template

from flask import jsonify, Response

# from cStringIO import StringIO as IO
# import gzip
# import functools
# from flask.ctx import after_this_request
# from flask.globals import request
# from flask.helpers import  url_for, send_file
# from datamonitor.datetime_utils import parseDate
# from werkzeug import redirect
# import os.path
# from datamonitor.timer import Timer