Commit 4bbf23c5 authored by Mitchell Moore's avatar Mitchell Moore Committed by Krish Moodbidri
Browse files

Include asyncronous delay. Remove old validate method. Add rough global username exchange

parent 2124c09b
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import os import os
import time import time
import subprocess import signal
import pika import pika
from flask_socketio import SocketIO from flask_socketio import SocketIO
...@@ -14,6 +14,7 @@ app = create_app(config_name) ...@@ -14,6 +14,7 @@ app = create_app(config_name)
app.config['SECRET_KEY'] = 'vnkdjnfjknfl1232#' app.config['SECRET_KEY'] = 'vnkdjnfjknfl1232#'
socketio = SocketIO(app) socketio = SocketIO(app)
global username_global
def messageReceived(methods=['GET', 'POST']): def messageReceived(methods=['GET', 'POST']):
print('message was received!!!') print('message was received!!!')
...@@ -42,25 +43,33 @@ def check_dir(user, interval): ...@@ -42,25 +43,33 @@ def check_dir(user, interval):
def create_account(username, fullname, reason): def create_account(username, fullname, reason):
# Todo: Ravi's and Louis's code go here # Todo: Ravi's and Louis's code goes here
print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue') print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue')
global username_global
username_global = username
socketio.emit("creating account") socketio.emit("creating account")
signal.signal(signal.SIGALRM, account_agent)
signal.alarm(5)
def account_confirmation(username): def account_agent(*args):
# Todo: Code to create a consumer based on the username goes here # Todo: Code to create a consumer based on the username goes here
# Todo: Goal is to have it listening for confirmation. # Todo: Goal is to have it listening for confirmation.
global username_global
username = username_global
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tAccount successfully created for ' + username)
socketio.emit("account ready")
return True return True
@socketio.on('user connect') @socketio.on('user connected')
def handle_my_custom_event(json, methods=['GET', 'POST']): def user_connected(json, methods=['GET', 'POST']):
username = json["user"] username = json["user"]
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' connected.') print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' connected.')
@socketio.on('request account') @socketio.on('request account')
def ingest_data(json, methods=['GET', 'POST']): def request_account(json, methods=['GET', 'POST']):
print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tQueue request received: ' + str(json)) print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tQueue request received: ' + str(json))
try: try:
...@@ -71,19 +80,5 @@ def ingest_data(json, methods=['GET', 'POST']): ...@@ -71,19 +80,5 @@ def ingest_data(json, methods=['GET', 'POST']):
socketio.emit("Account creation failed") socketio.emit("Account creation failed")
@socketio.on("validate creation")
def creation_confirmation(json, methods=['GET', 'POST']):
# User create Script Approach
username = json["username"]
if account_confirmation(username):
print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tAccount successfully created for ' + username)
socketio.emit("Account created")
else:
socketio.emit("Account creation failed")
if __name__ == '__main__': if __name__ == '__main__':
app.run(Debug=True) app.run(Debug=True)
Supports Markdown
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