walib package

Subpackages

Submodules

walib.configManager module

walib.databaseManager module

walib.procedure module

walib.resource module

walib.resourceFactory module

walib.resourceFactory.initResource(waEnviron)

walib.sqlschema module

walib.utils module

class walib.utils.FakeConfig

Bases: object

class walib.utils.Object

Bases: object

walib.utils.encodeobject(obj, encoding='utf-8')
walib.utils.getFoiNamesList(pgdb, service, offering=None)

Return the list of observed properties

@param pgdb: service connection @type pgdb: L{wa.databaseManager.PgDB} object @param service: service name @type service: L{string} @param offering: filter procedures by this offering name @type offering: C{string} or C{None} @return: C{list} of C{dict} with observed property C{id} and C{name} keys

>>> Return example:
    [
        {
            "id": 1,
            "name": "urn:ogc:def:parameter:x-istsos:1.0:lake:water:height"
        },
        {
            "id": 2,
            "name": "urn:ogc:def:parameter:x-istsos:1.0:meteo:air:rainfall"
        }
    ]
walib.utils.getGeoJSONFromProcedure(pgdb, service, procedure, epsg)
>>> Return example:
    {
        "type":"Point",
        "coordinates":[8.961, 46.027, 344.100]
    }
walib.utils.getObsPropNamesList(pgdb, service, offering=None)

Return the list of observed properties

@param pgdb: service connection @type pgdb: L{wa.databaseManager.PgDB} object @param service: service name @type service: L{string} @param offering: filter procedures by this offering name @type offering: C{string} or C{None} @return: C{list} of C{dict} with observed property C{id} and C{name} keys

>>> Return example:
    [
        {
            "id": 1,
            "name": "urn:ogc:def:parameter:x-istsos:1.0:lake:water:height"
        },
        {
            "id":2,
            "name": "urn:ogc:def:parameter:x-istsos:1.0:meteo:air:rainfall"
        }
    ]
walib.utils.getObservationPeriod(pgdb, service, procedures)

Return the list of procedures with observation periods

@param pgdb: service connection @type pgdb: L{wa.databaseManager.PgDB} object @param service: service name @type service: L{string} @param procedures: procedures @type procedure: C{list} of C{string} @return: C{list} of C{dict} with procedure, stime (start time)

and etime (end time) keys
>>> Return example:
    [
        {
            "procedure": "P_TRE",
            "stime": "2000-12-31T23:00:00Z",
            "etime": "2012-12-31T23:00:00Z"
        },
        {
            "procedure": "P_ BOD",
            "stime": "1986-12-31T23:00:00Z",
            "etime": "2012-12-31T23:00:00Z"
        }
    ]
walib.utils.getObservedPropertiesFromProcedure(pgdb, service, procedure)

Return the list of observed properties related to the given procedure

@param pgdb: service connection @type pgdb: L{wa.databaseManager.PgDB} object @param service: service name @type service: L{string} @param procedureID: filter procedure id @type procedure: C{string} or C{None} @return: C{list} of C{dict} with observed property C{id} and C{name} keys

>>> Return example:
    [
        {
            "id": 1,
            "def": "urn:ogc:def:parameter:x-istsos:1.0:lake:water:height",
            "name": "lake-water-height"
        },
        {
            "id": 2,
            "def": "urn:ogc:def:parameter:x-istsos:1.0:meteo:air:rainfall",
            "name": "lake-air-rainfall"
        }
    ]
walib.utils.getOfferingDetailsList(pgdb, service)

Return the list of offerings details for a given istsos service connection

@param pgdb: service connection @type pgdb: L{wa.databaseManager.PgDB} object @param service: service name @type service: L{string} @return: C{list} of C{dict} with offering C{id} and C{name} keys

>>> Return example:
    [
        {
            "name": "temperature",
            "description": "descrizione 3",
            "procedures": 12,
            "expiration": "22.12.2012",
            "active": true
        },
        {
            "name": "water",
            "description": "descrizione 3",
            "procedures": 22,
            "expiration": "22.12.2012",
            "active": true
        },
        {
            "name": "air",
            "description": "descrizione 3",
            "procedures": 3,
            "expiration": "22.12.2012",
            "active": true
        }
    ]
walib.utils.getOfferingNamesList(pgdb, service)

Return the list of offerings for a give istsos service connection

@param pgdb: service connection @type pgdb: L{wa.databaseManager.PgDB} object @param service: service name @type service: L{string} @return: C{list} of C{dict} with offering C{id} and C{name} keys

>>> Return example:
    [
        { "id":1,"name":"temporary"},
        { "id":2,"name":"water"},
        { "id":3,"name":"air"}
    ]
walib.utils.getOfferingsFromProcedure(pgdb, service, procedure)

Return the list of offerings related to the given procedure

@param pgdb: service connection @type pgdb: L{wa.databaseManager.PgDB} object @param service: service name @type service: L{string} @param procedureID: filter procedure id @type procedure: C{string} or C{None} @return: C{list} of C{dict} with observed property C{id} and C{name} keys

>>> Return example:
    [
        {
            "id": 1,
            "name": "urn:ogc:def:parameter:x-istsos:1.0:lake:water:height"
        },
        {
            "id": 2,
            "name": "urn:ogc:def:parameter:x-istsos:1.0:meteo:air:rainfall"
        }
    ]
walib.utils.getProcedureNamesList(pgdb, service, offering=None, observationType=None, procedure=None)

Return the list of procedures:

The list can be filtered by offering and/or observationType

@param pgdb: service connection @type pgdb: L{wa.databaseManager.PgDB} object @param service: service name @type service: L{string} @param offering: filter procedures by this offering name @type offering: C{string} or C{None} @type observationType: C{string} or C{None} @return: C{list} of C{dict} with procedure C{id} and C{name} keys

>>> Return example:
    [
        {
          "id":1,
          "name":"Chiasso",
          "description": "",
          "assignedid": "1234",
          "sensortype": "in-situ-fixed",
          "samplingTime": {
            "beginposition": "2015-10-08T02:56:16+01",
            "endposition": "2015-10-08T08:56:16+01"
          }
        },
        {...}
    ]
walib.utils.getServiceList(servicepath, listonly=False)

Return the list of istsos services

@param servicepath: path to service folder @param listonly: define if only service list is requested

(optional - default L{False})

@param type: L{boolean} @return: return a list of services

>>> Return example with listonly==True :
    [name1,name2,...]
>>> Return example with listonly==False:
    [
        {"service":name1,"path":path1},
        {"service":name1,"path":path1},
        ...
    ]
walib.utils.preventInjection(sql)

Parse given sql with regex for possible malicious sql ignection

@param sql: text to parse @param type: L{string} @return: L{True} if no malicious sql ingnection was detected

walib.utils.to_unicode_or_bust(obj, encoding='utf-8')
walib.utils.valid_NCName(name)
walib.utils.validateJsonConstraint(constraint)
Permitted conigurations:
{“role”:”urn:ogc:def:classifiers:x-istsos:1.0:qualityIndexCheck:level0”,”min”:”10”} {“role”:”urn:ogc:def:classifiers:x-istsos:1.0:qualityIndexCheck:level0”,”max”:”10”} {“role”:”urn:ogc:def:classifiers:x-istsos:1.0:qualityIndexCheck:level0”,”interval”:[“-10”,”10”]} {“role”:”urn:ogc:def:classifiers:x-istsos:1.0:qualityIndexCheck:level0”,”valueList”:[“1”,”2”,”3”,”4”,”5”,”6”]}
walib.utils.validatedb(user, password, dbname, host, port=5432, service=None)

Validate a service db connection parameters

@param user: user name used to authenticate @param password: password used to authenticate @param dbname: the database name (only in dsn string) @param host: database host address @param port: onnection port number (optional - defaults to 5432) @param service: service name that correspond with associated database

schema (optional)
@return: L{True} if connection could be estabished and the schema found
(only if schema is provided)
walib.utils.verifyxmlservice(url, waEnviron)

walib.wa_version module

Module contents