Newer
Older
from celery import Celery
import time
from flask_socketio import SocketIO
Cloud User
committed
import subprocess
from gevent import monkey
monkey.patch_all(subprocess=True)
Ravi Tripathi
committed
broker_url = 'amqp://reggie:reggie@ohpc:5672/'
Cloud User
committed
#broker_url = 'amqp://'
celery = Celery('flask_user_reg', broker=broker_url)
#socketio = SocketIO(message_queue='amqp:///socketio')
Ravi Tripathi
committed
socketio = SocketIO(message_queue='amqp://reggie:reggie@ohpc:5672/socketio')
Ravi Tripathi
committed
def send_msg(event, room):
print("Post '{}' to room '{}'".format(event,room))
socketio.emit(event, room=room)
Ravi Tripathi
committed
def celery_create_account(username, fullname, reason, session):
room = session
# Todo: Ravi's and Louis's code goes here
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue')
Ravi Tripathi
committed
send_msg('creating account', room)
#socketio.emit("creating account", room=room)
Cloud User
committed
print(username)
subprocess.call(["/opt/rabbitmq_agents/flask_producer.py", "ohpc_account_create", username])
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tAccount successfully created for ' + username)
Ravi Tripathi
committed
send_msg('account ready', room)
#socketio.emit('account ready', room=room)