linotp.lib.reporting module

class linotp.lib.reporting.ReportingIterator(page=None, psize=None, sort=None, sortdir=None, realms=None, status=None, date=None)[source]

Bases: object

support a smooth iterating through lines in reporting table

getResultSetInfo()[source]
next()[source]
linotp.lib.reporting.and_(*clauses)

Produce a conjunction of expressions joined by AND.

E.g.:

from sqlalchemy import and_

stmt = select([users_table]).where(
                and_(
                    users_table.c.name == 'wendy',
                    users_table.c.enrolled == True
                )
            )

The and_() conjunction is also available using the Python & operator (though note that compound expressions need to be parenthesized in order to function with Python operator precedence behavior):

stmt = select([users_table]).where(
                (users_table.c.name == 'wendy') &
                (users_table.c.enrolled == True)
            )

The and_() operation is also implicit in some cases; the Select.where() method for example can be invoked multiple times against a statement, which will have the effect of each clause being combined using and_():

stmt = select([users_table]).\
            where(users_table.c.name == 'wendy').\
            where(users_table.c.enrolled == True)

See also

or_()

linotp.lib.reporting.delete(realms, status, date=None)[source]

delete all rows in reporting database before a given date

Parameters:date (string in format: 'yyyy-mm-dd') – (optional)day until which all rows will be deleted
Returns:number of deleted rows
linotp.lib.reporting.get_max(realm, status='active')[source]
get the maximum number of tokens (with given status) in a realm in the whole
reporting database; if no status is given, ‘active’ is default
Parameters:
  • realm – (required) the realm in which we are searching
  • status – (default: ‘active’) the status that the tokens have defaukt is active as this is relevant for license
Returns:

maximum number of reported tokens with given status in realm

linotp.lib.reporting.or_(*clauses)

Produce a conjunction of expressions joined by OR.

E.g.:

from sqlalchemy import or_

stmt = select([users_table]).where(
                or_(
                    users_table.c.name == 'wendy',
                    users_table.c.name == 'jack'
                )
            )

The or_() conjunction is also available using the Python | operator (though note that compound expressions need to be parenthesized in order to function with Python operator precedence behavior):

stmt = select([users_table]).where(
                (users_table.c.name == 'wendy') |
                (users_table.c.name == 'jack')
            )

See also

and_()

linotp.lib.reporting.token_reporting(event, tokenrealms)[source]

log token events into reporting table

Parameters:
  • event – the event that happened, e.g. init token, delete token
  • tokenrealms – the realm on which the event happened
Returns:

nothing