Skip to content
Snippets Groups Projects
Commit 86186e97 authored by Mitchell Moore's avatar Mitchell Moore
Browse files

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

parent e946d2e2
No related branches found
No related tags found
No related merge requests found
......@@ -2,7 +2,7 @@
import os
import time
import subprocess
import signal
import pika
from flask_socketio import SocketIO
......@@ -14,6 +14,7 @@ app = create_app(config_name)
app.config['SECRET_KEY'] = 'vnkdjnfjknfl1232#'
socketio = SocketIO(app)
global username_global
def messageReceived(methods=['GET', 'POST']):
print('message was received!!!')
......@@ -42,25 +43,33 @@ def check_dir(user, interval):
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')
global username_global
username_global = username
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: 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
@socketio.on('user connect')
def handle_my_custom_event(json, methods=['GET', 'POST']):
@socketio.on('user connected')
def user_connected(json, methods=['GET', 'POST']):
username = json["user"]
print(time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' connected.')
@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))
try:
......@@ -71,20 +80,6 @@ def ingest_data(json, methods=['GET', 'POST']):
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__':
# app.run()
socketio.run(app)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment