Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Krish Moodbidri
user-reg-cleanup
Commits
4bbf23c5
Commit
4bbf23c5
authored
Feb 20, 2020
by
Mitchell Moore
Committed by
Krish Moodbidri
Apr 10, 2020
Browse files
Include asyncronous delay. Remove old validate method. Add rough global username exchange
parent
2124c09b
Changes
1
Hide whitespace changes
Inline
Side-by-side
run.py
View file @
4bbf23c5
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
import
os
import
os
import
time
import
time
import
s
ubprocess
import
s
ignal
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 go
es
here
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
'
\t
User '
+
username
+
' added to queue'
)
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
'
\t
User '
+
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"
)
+
'
\t
Account successfully created for '
+
username
)
socketio
.
emit
(
"account ready"
)
return
True
return
True
@
socketio
.
on
(
'user connect'
)
@
socketio
.
on
(
'user connect
ed
'
)
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"
)
+
'
\t
User '
+
username
+
' connected.'
)
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
'
\t
User '
+
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"
)
+
'
\t
Queue request received: '
+
str
(
json
))
print
(
time
.
strftime
(
"%m-%d-%Y_%H:%M:%S"
)
+
'
\t
Queue 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"
)
+
'
\t
Account 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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment