Commit 9c756ddd authored by Krish Moodbidri's avatar Krish Moodbidri Committed by Mitchell Moore
Browse files

Added a variable file to be used by flask and celery

- Added vars file to be used by run.py and tasks.py
- Fixed type Key to key
- Added username and password as variables
- Removed print statemt
- Fix variable mismatch
parent 633397ce
......@@ -4,6 +4,7 @@ import os
import time
import signal
import tasks
import vars
from flask import session
from flask_socketio import SocketIO, join_room
......@@ -15,8 +16,8 @@ monkey.patch_all(subprocess=True)
config_name = os.getenv('FLASK_CONFIG')
app = create_app(config_name)
app.config['SECRET_KEY'] = 'vnkdjnfjknfl1232#'
socketio = SocketIO(app, message_queue='amqp://reggie:reggie@ohpc:5672/socketio')
app.config['SECRET_KEY'] = vars.key
socketio = SocketIO(app, message_queue= vars.message_queue)
@socketio.on('join_room')
......@@ -30,10 +31,10 @@ def on_room():
@socketio.on('request account')
def request_account(json, methods=['GET', 'POST']):
print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tQueue request received: ' + str(json))
sid = str(session['uid'])
print("Room: {}".format(sid))
room = str(session['uid'])
print("Room: {}".format(room))
try:
tasks.celery_create_account.delay(json['username'], json['fullname'], json['reason'], session=sid)
tasks.celery_create_account.delay(json['username'], json['fullname'], json['reason'], session=room)
except Exception as e:
print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in account creation: ", e)
socketio.emit("Account creation failed", room)
......
......@@ -2,14 +2,15 @@ from celery import Celery
import time
from flask_socketio import SocketIO
import subprocess
import vars
from gevent import monkey
monkey.patch_all(subprocess=True)
broker_url = 'amqp://reggie:reggie@ohpc:5672/'
broker_url = vars.broker_url
celery = Celery('flask_user_reg', broker=broker_url)
socketio = SocketIO(message_queue='amqp://reggie:reggie@ohpc:5672/socketio')
socketio = SocketIO(message_queue=vars.message_queue)
def send_msg(event, room):
print("Post '{}' to room '{}'".format(event,room))
......
id = 'reggie'
password = 'reggie'
key = 'vnkdjnfjknfl1232'
broker_url = 'amqp://' + id + ':' + password + '@ohpc:5672/'
message_queue = broker_url + 'socketio'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment