def add(): u = Update(msg='Added from command-line') with webapp.app_context(): print('Committing to database ...') db.session.add(u) db.session.commit() send_update(u) print('Added.')
def add(): u = Update(msg='Added from command-line') with webapp.app_context(): print 'Committing to database ...' db.session.add(u) db.session.commit() send_update(u) print 'Added.'
def listen_thread(): r = redis.StrictRedis() pubsub = r.pubsub() pubsub.subscribe([config.REDIS_CHANNEL]) for item in pubsub.listen(): if item['data'] == "KILL": pubsub.unsubscribe() print 'REDIS - unsubscribed and finished' break elif item['data'] != 1: print 'REDIS -', item['channel'], ":", item['data'] with webapp.app_context(): data = json.loads(item['data']) socketio.emit( 'new_update', data['msg'] + ' at ' + data['timestamp'], namespace='/browser', )
def listen_thread(): r = redis.StrictRedis() pubsub = r.pubsub() pubsub.subscribe([config.REDIS_CHANNEL]) for item in pubsub.listen(): if item['data'] == "KILL": pubsub.unsubscribe() print('REDIS - unsubscribed and finished') break elif item['data'] != 1: print('REDIS -', item['channel'], ":", item['data']) with webapp.app_context(): data = json.loads(item['data']) socketio.emit( 'new_update', data['msg'] + ' at ' + data['timestamp'], namespace='/browser', )
def listen_thread(): ctx = zmq.Context() # Reply - act as server socket = ctx.socket(zmq.REP) socket.bind('tcp://*:%s' % config.ZEROMQ_PORT) while True: request = socket.recv() print 'ZEROMQ request -', request socket.send('OK') if request == 'KILL': socket.close() print 'Socket closed.' break with webapp.app_context(): data = json.loads(request) print 'Sending to SocketIO ...' socketio.emit( 'new_update', data['msg'] + ' at ' + data['timestamp'], namespace='/browser', )
def listen_thread(): ctx = zmq.Context() # Reply - act as server socket = ctx.socket(zmq.REP) socket.bind('tcp://*:%s' % config.ZEROMQ_PORT) while True: request = socket.recv() print('ZEROMQ request -', request) socket.send('OK') if request == 'KILL': socket.close() print('Socket closed.') break with webapp.app_context(): data = json.loads(request) print('Sending to SocketIO ...') socketio.emit( 'new_update', data['msg'] + ' at ' + data['timestamp'], namespace='/browser', )
def delete(): with webapp.app_context(): models.Update.query.delete() db.session.commit() print 'Deleted all updates.'
def delete(): with webapp.app_context(): models.Update.query.delete() db.session.commit() print('Deleted all updates.')