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

Add rough Todo comments for RabbitMQ implementation

parent c1b8afe5
No related branches found
No related tags found
1 merge request!35Version 1b openstack rabbitmq
...@@ -18,6 +18,8 @@ def messageReceived(methods=['GET', 'POST']): ...@@ -18,6 +18,8 @@ def messageReceived(methods=['GET', 'POST']):
def check_dir(user, interval): def check_dir(user, interval):
# Todo: Make this mothod in a consumer
""" """
:param user: (string) username to check for in DB. :param user: (string) username to check for in DB.
:param interval: (int) Frequency to check in seconds. :param interval: (int) Frequency to check in seconds.
...@@ -47,34 +49,40 @@ def handle_my_custom_event(json, methods=['GET', 'POST']): ...@@ -47,34 +49,40 @@ def handle_my_custom_event(json, methods=['GET', 'POST']):
def ingest_data(json, methods=['GET', 'POST']): def ingest_data(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: # Todo: Insert rabbitMQ implementation here
fullname = json["fullname"] # Todo: Make this part of the method a producer
reason = json["reason"] # Todo: Make the remaining protion of this method in a RabbitMQ consumer
username = json["username"]
# try:
time_stamp = time.strftime("%m-%d-%Y_%H:%M:%S") # fullname = json["fullname"]
directory = "flat_db/" # reason = json["reason"]
complete_file_name = os.path.join(directory, time_stamp + "_" + username + ".txt") # username = json["username"]
#
if not os.path.exists(directory): # time_stamp = time.strftime("%m-%d-%Y_%H:%M:%S")
os.makedirs(directory) # directory = "flat_db/"
# complete_file_name = os.path.join(directory, time_stamp + "_" + username + ".txt")
file = open(complete_file_name, "w") # create time stamped file to be queued #
# if not os.path.exists(directory):
file.write(fullname + "\n") # os.makedirs(directory)
file.write(reason) #
# file = open(complete_file_name, "w") # create time stamped file to be queued
file.close() #
print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue') # file.write(fullname + "\n")
socketio.emit("creating account") # file.write(reason)
#
except Exception as e: # file.close()
print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in directory creation: ", e) # print (time.strftime("%m-%d-%Y_%H:%M:%S") + '\tUser ' + username + ' added to queue')
socketio.emit("Account creation failed") # socketio.emit("creating account")
#
# except Exception as e:
# print(time.strftime("%m-%d-%Y_%H:%M:%S") + "\tError in directory creation: ", e)
# socketio.emit("Account creation failed")
@socketio.on("validate creation") @socketio.on("validate creation")
def creation_confirmation(json, methods=['GET', 'POST']): def creation_confirmation(json, methods=['GET', 'POST']):
# Todo: Make this mthod in a RabbitMQ consumer
username = json["username"] username = json["username"]
if check_dir(username, 10): if check_dir(username, 10):
......
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