Exemplo n.º 1
0
def prepareautomaticrecommunication():
    ''' reinjects all files for which communication failed (status = RAWOUT)
    '''
    retransmit = False  #indicate retransmit
    #bots keeps track of last time automaticretrycommunication was done; reason is mainly performance
    startidta = max(
        botslib.keeptrackoflastretry('bots__automaticretrycommunication',
                                     botslib.getlastrun()),
        botslib.get_idta_last_error())
    #reinject
    for row4 in botslib.query(
            '''SELECT idta
                                FROM  ta
                                WHERE idta>%(startidta)s
                                AND   status=%(status)s 
                                AND   statust=%(statust)s ''', {
                'statust': OK,
                'status': RAWOUT,
                'startidta': startidta
            }):
        retransmit = True
        ta_outgoing = botslib.OldTransaction(row4['idta'])
        ta_outgoing_copy = ta_outgoing.copyta(status=RAWOUT, statust=OK)
        ta_outgoing.update(statust=DONE)
    return retransmit
Exemplo n.º 2
0
def routedispatcher(routestorun, type=None):
    ''' run all route(s). '''
    if type == '--retransmit':
        if not prepareretransmit():
            return 0
    elif type == '--retrycommunication':
        if not preparerecommunication():
            return 0
    elif type == '--automaticretrycommunication':
        if not prepareautomaticrecommunication():
            return 0
    elif type == '--retry':
        if not prepareretry():
            return 0
    stuff2evaluate = botslib.getlastrun()
    botslib.set_minta4query()
    for route in routestorun:
        foundroute = False
        botslib.setpreprocessnumber(SET_FOR_PROCESSING)
        for routedict in botslib.query(
                '''SELECT idroute     ,
                                                 fromchannel_id as fromchannel,
                                                 tochannel_id as tochannel,
                                                 fromeditype,
                                                 frommessagetype,
                                                 alt,
                                                 frompartner_id as frompartner,
                                                 topartner_id as topartner,
                                                 toeditype,
                                                 tomessagetype,
                                                 seq,
                                                 frompartner_tochannel_id,
                                                 topartner_tochannel_id,
                                                 testindicator,
                                                 translateind,
                                                 defer
                                        FROM routes
                                        WHERE idroute=%(idroute)s
                                        AND   active=%(active)s
                                        ORDER BY seq''', {
                    'idroute': route,
                    'active': True
                }):
            botsglobal.logger.info(_(u'running route %(idroute)s %(seq)s'), {
                'idroute': routedict['idroute'],
                'seq': routedict['seq']
            })
            botslib.setrouteid(routedict['idroute'])
            foundroute = True
            router(routedict)
            botslib.setrouteid('')
            botsglobal.logger.debug(u'finished route %s %s',
                                    routedict['idroute'], routedict['seq'])
        if not foundroute:
            botsglobal.logger.warning(_(u'there is no (active) route "%s".'),
                                      route)
    return stuff2evaluate
Exemplo n.º 3
0
def routedispatcher(routestorun,type=None):
    ''' run all route(s). '''
    if type == '--retransmit':
        if not prepareretransmit():
            return 0
    elif type == '--retrycommunication':
        if not preparerecommunication():
            return 0
    elif type == '--automaticretrycommunication':
        if not prepareautomaticrecommunication():
            return 0
    elif type == '--retry':
        if not prepareretry():
            return 0
    stuff2evaluate = botslib.getlastrun()
    botslib.set_minta4query()
    for route in routestorun:
        foundroute=False
        botslib.setpreprocessnumber(SET_FOR_PROCESSING)
        for routedict in botslib.query('''SELECT idroute     ,
                                                 fromchannel_id as fromchannel,
                                                 tochannel_id as tochannel,
                                                 fromeditype,
                                                 frommessagetype,
                                                 alt,
                                                 frompartner_id as frompartner,
                                                 topartner_id as topartner,
                                                 toeditype,
                                                 tomessagetype,
                                                 seq,
                                                 frompartner_tochannel_id,
                                                 topartner_tochannel_id,
                                                 testindicator,
                                                 translateind,
                                                 defer
                                        FROM routes
                                        WHERE idroute=%(idroute)s
                                        AND   active=%(active)s
                                        ORDER BY seq''',
                                        {'idroute':route,'active':True}):
            botsglobal.logger.info(_(u'running route %(idroute)s %(seq)s'),{'idroute':routedict['idroute'],'seq':routedict['seq']})
            botslib.setrouteid(routedict['idroute'])
            foundroute=True
            router(routedict)
            botslib.setrouteid('')
            botsglobal.logger.debug(u'finished route %s %s',routedict['idroute'],routedict['seq'])
        if not foundroute:
            botsglobal.logger.warning(_(u'there is no (active) route "%s".'),route)
    return stuff2evaluate
Exemplo n.º 4
0
def prepareretry():
    ''' reinjects all files for which communication failed (status = RAWOUT)
    '''
    retransmit = False  #indicate retransmit
    #bots keeps track of last time retry was done; reason is mainly performance
    startidta = max(botslib.keeptrackoflastretry('bots__retry',botslib.getlastrun()),botslib.get_idta_last_error())
    #reinject
    for row4 in botslib.query('''SELECT idta,status
                                FROM  ta
                                WHERE idta>%(startidta)s
                                AND   statust=%(statust)s ''',
                                {'statust':OK,'startidta':startidta}):
        retransmit = True
        ta_outgoing = botslib.OldTransaction(row4['idta'])
        ta_outgoing_copy = ta_outgoing.copyta(status=row4['status'],statust=OK)
        ta_outgoing.update(statust=DONE)
    return retransmit