(rid, rdb, r_server, logger)
return success
This method will be called to change a users status in the db
This method will be called to change a users status in the db
This method will be called to change a users status in the db
def chlastrun(rid, rdb, r_server, logger):
    ''' This method will be called to change a users status in the db '''
    lastrun = time.time()
    success = False
    cacheonly = False

    # First set rethinkdb
    try:
        results = r.table('reactions').get(
            rid).update({'lastrun': lastrun}).run(rdb)
        if results['replaced'] == 1:
            line = "update-lastrun: RethinkDB lastrun for %s is now set to: %r" % (rid, lastrun)
            logger.info(line)
            success = True
        else:
            success = False
            cacheonly = True
    except (RqlRuntimeError, RqlDriverError) as e:
        line = "update-lastrun: Rethinkdb is inaccessible cannot change lastrun for %s" % rid
        logger.info(line)
        line = "update-lastrun: Rethinkdb Error: %s" % e.message
        logger.info(line)
        success = False
        cacheonly = True

    # Then set redis cache
    try:
        r_server.set("reaction:" + rid + ':lastrun', lastrun)
        line = "update-lastrun: Redis lastrun for %s is now set to: %r" % (
            rid, lastrun)
        logger.info(line)
        success = True
    except:
        line = "update-lastrun: Redis is inaccessible cannot change lastrun for %s" % rid
        logger.info(line)
        success = False

    return success
def chlastrun ( rid , rdb , r_server , logger ) : lastrun = time . time ( ) success = False cacheonly = False # First set rethinkdb try : results = r . table ( 'reactions' ) . get ( rid ) . update ( { 'lastrun' : lastrun } ) . run ( rdb ) if results [ 'replaced' ] == 1 : line = "update-lastrun: RethinkDB lastrun for %s is now set to: %r" % ( rid , lastrun ) logger . info ( line ) success = True else : success = False cacheonly = True except ( RqlRuntimeError , RqlDriverError ) as e : line = "update-lastrun: Rethinkdb is inaccessible cannot change lastrun for %s" % rid logger . info ( line ) line = "update-lastrun: Rethinkdb Error: %s" % e . message logger . info ( line ) success = False cacheonly = True # Then set redis cache try : r_server . set ( "reaction:" + rid + ':lastrun' , lastrun ) line = "update-lastrun: Redis lastrun for %s is now set to: %r" % ( rid , lastrun ) logger . info ( line ) success = True except : line = "update-lastrun: Redis is inaccessible cannot change lastrun for %s" % rid logger . info ( line ) success = False return success