Exemple #1
0
def getContent(connstr, outer_id, **kwargs):

    headers, row = DBOperator(connstr).getContent(outer_id)
    result = _dbAsText(headers, [row])
    if kwargs.get('args') is not None \
            and 'full' in kwargs.get('args') \
            and len(row) > 0:
        content_id = row[headers.index('id')]
        result = result + '\nRESOURCES\n'
        result = result + _dbAsText(
            *DBOperator(connstr).getResourceByContentID(content_id))

    return result
Exemple #2
0
def delContent(connstr, outer_id, **kwargs):
    """
    Deletes custom resource to the database's Resource table.
    :param connstr: smth like "engine://*****:*****@host:port/dbname"
    :return: True if deleted, False otherwise
    """
    return DBOperator(connstr).delContent(outer_id)
Exemple #3
0
def unlockJobs(connstr, procname=None, **kwargs):
    """
    Sets exit_code and result of the all log entires with empty exit_code.
    :param connstr: smth like "engine://*****:*****@host:port/dbname"
    :param procname: specify procname to unlock
    :return: Affected entries count.
    """
    if procname == 'all':
        procname = None

    return DBOperator(connstr).unlockJobs(procname)
Exemple #4
0
def findResource(connstr, value, entitytype=None, **kwargs):
    """
    Adds custom resource to the database's Resource table.
    :param connstr: smth like "engine://*****:*****@host:port/dbname"
    :return: row ID or None for erroneous entitytype
    """
    if kwargs.get('args') is None:
        kwargs['args'] = []
    if entitytype == 'all':
        entitytype = None
    return _dbAsText(
        *DBOperator(connstr).findResource(value, entitytype, *kwargs['args']))
Exemple #5
0
def delCustomResource(connstr, entitytype, value, **kwargs):
    """
    Deletes custom resource to the database's Resource table.
    :param connstr: smth like "engine://*****:*****@host:port/dbname"
    :return: True if deleted, False otherwise
    """
    try:
        return (DBOperator(connstr).delCustomResource(
            entitytype=entitytype,
            value=value,
        ))
    except KeyError:
        return "Entity type error"
Exemple #6
0
def getLastJobs(connstr, procname=None, **kwargs):

    if kwargs.get('args') is None:
        count = 10
    elif len(kwargs['args']) == 0:
        count = 10
    else:
        count = kwargs['args'][0]

    if procname == 'all':
        procname = None

    return _dbAsText(*DBOperator(connstr).getLastJobs(procname, count))
Exemple #7
0
def addCustomResource(connstr, entitytype, value, **kwargs):
    """
    Adds custom resource to the database's Resource table.
    :param connstr: smth like "engine://*****:*****@host:port/dbname"
    :return: row ID or None for erroneous entitytype
    """
    try:
        if not checks[entitytype](value):
            return 'Value error'
    except KeyError:
        # No checks for this entity type, but going ahead.
        pass
    try:
        return (DBOperator(connstr).addCustomResource(
            entitytype=entitytype,
            value=value,
        ))
    except KeyError:
        return "Entity type error"
Exemple #8
0
def showDumpStats(connstr, **kwargs):
    return _dbAsText(*DBOperator(connstr).getBlockCounters())
Exemple #9
0
def getDecisionByID(connstr, outer_id, **kwargs):
    return _dbAsText(*DBOperator(connstr).getDecisionByOuterID(outer_id))
Exemple #10
0
def getDecsnInfo(connstr, de_id, **kwargs):
    return _dbAsText(*DBOperator(connstr).getDecisionByID(de_id))
Exemple #11
0
def getActiveJobs(connstr, procname=None, **kwargs):
    if procname == 'all':
        procname = None
    return _dbAsText(*DBOperator(connstr).getActiveJobs(procname))
Exemple #12
0
def showDumpInfo(connstr, **kwargs):
    return '\n'.join(
        str(k).ljust(16) + '\t' + str(v)
        for k, v in DBOperator(connstr).getLastDumpInfo().items())
Exemple #13
0
def getLastExitCode(connstr, procname, **kwargs):
    return DBOperator(connstr).getLastExitCode(procname)