Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
account_init_cleanup
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krish Moodbidri
account_init_cleanup
Commits
91eb91f9
Commit
91eb91f9
authored
5 years ago
by
Bo-Chun Chen
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'ravi/cleanup' into add_rabbitmq_connection
Conflicts: run.py
parents
b2a5e4c2
95352a2b
No related branches found
Branches containing commit
Tags
v1.3
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app/__init__.py
+0
-5
0 additions, 5 deletions
app/__init__.py
app/templates/auth/SignUp.html
+0
-3
0 additions, 3 deletions
app/templates/auth/SignUp.html
run.py
+3
-19
3 additions, 19 deletions
run.py
tasks.py
+0
-7
0 additions, 7 deletions
tasks.py
with
3 additions
and
34 deletions
app/__init__.py
+
0
−
5
View file @
91eb91f9
...
...
@@ -17,10 +17,6 @@ def create_app(config_name):
@app.route
(
'
/
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
# initial route to display the reg page
def
index
():
#if 'username' not in session:
# session['username'] = "name_test" + str(random.randint(0, 10000))
# #session['username'] = session['bid']
if
'
uid
'
not
in
session
:
session
[
'
uid
'
]
=
str
(
uuid
.
uuid4
())
...
...
@@ -28,7 +24,6 @@ def create_app(config_name):
session
[
'
return_url
'
]
=
request
.
args
.
get
(
"
redir
"
)
or
"
/pun/sys/dashboard
"
return
render_template
(
'
auth/SignUp.html
'
,
room_id
=
session
[
'
uid
'
])
#return render_template('auth/SignUp.html', user=session['username'], room_id=session['uid'])
# misc page error catching
@app.errorhandler
(
403
)
...
...
This diff is collapsed.
Click to expand it.
app/templates/auth/SignUp.html
+
0
−
3
View file @
91eb91f9
...
...
@@ -10,9 +10,6 @@
var
socket
=
io
.
connect
(
'
http://
'
+
document
.
domain
+
'
:
'
+
location
.
port
);
socket
.
on
(
'
connect
'
,
function
()
{
/* socket.emit( 'user connected', {
user: document.getElementById("username").innerText
} ) */
socket
.
emit
(
'
join_room
'
)
socket
.
on
(
'
creating account
'
,
function
(
msg
)
{
...
...
This diff is collapsed.
Click to expand it.
run.py
+
3
−
19
View file @
91eb91f9
...
...
@@ -17,20 +17,10 @@ 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
'
)
#socketio = SocketIO(app)
#socketio = SocketIO(app, message_queue='amqp:///socketio')
@socketio.on
(
'
user connected
'
)
def
user_connected
(
json
,
methods
=
[
'
GET
'
,
'
POST
'
]):
username
=
json
[
"
user
"
]
room
=
str
(
session
[
'
uid
'
])
join_room
(
room
)
print
(
time
.
strftime
(
"
%m-%d-%Y_%H:%M:%S
"
)
+
'
\t
User
'
+
username
+
'
connected.
'
)
print
(
'
\t\t\t
|-----Room ID:
'
+
room
)
@socketio.on
(
'
connect
'
)
def
socket_connect
():
pass
@socketio.on
(
'
join_room
'
)
def
on_room
():
...
...
@@ -43,14 +33,9 @@ def on_room():
@socketio.on
(
'
request account
'
)
def
request_account
(
json
,
methods
=
[
'
GET
'
,
'
POST
'
]):
print
(
time
.
strftime
(
"
%m-%d-%Y_%H:%M:%S
"
)
+
'
\t
Queue request received:
'
+
str
(
json
))
#print(json)
sid
=
str
(
session
[
'
uid
'
])
#join_room(room)
print
(
"
Room: {}
"
.
format
(
sid
))
#socketio.emit("creating account", room=sid)
try
:
# create_account(json['username'], json['fullname'], json['reason'])
#tasks.celery_create_account.delay(json['username'], json['fullname'], json['reason'], room, socketio, session=room)
tasks
.
celery_create_account
.
delay
(
json
[
'
username
'
],
json
[
'
fullname
'
],
json
[
'
reason
'
],
session
=
sid
)
except
Exception
as
e
:
print
(
time
.
strftime
(
"
%m-%d-%Y_%H:%M:%S
"
)
+
"
\t
Error in account creation:
"
,
e
)
...
...
@@ -58,5 +43,4 @@ def request_account(json, methods=['GET', 'POST']):
if
__name__
==
'
__main__
'
:
# app.run()
socketio
.
run
(
app
,
host
=
'
0.0.0.0
'
)
This diff is collapsed.
Click to expand it.
tasks.py
+
0
−
7
View file @
91eb91f9
...
...
@@ -7,10 +7,8 @@ from gevent import monkey
monkey
.
patch_all
(
subprocess
=
True
)
broker_url
=
'
amqp://reggie:reggie@ohpc:5672/
'
#broker_url = 'amqp://'
celery
=
Celery
(
'
flask_user_reg
'
,
broker
=
broker_url
)
#socketio = SocketIO(message_queue='amqp:///socketio')
socketio
=
SocketIO
(
message_queue
=
'
amqp://reggie:reggie@ohpc:5672/socketio
'
)
def
send_msg
(
event
,
room
):
...
...
@@ -20,14 +18,9 @@ def send_msg(event, room):
@celery.task
def
celery_create_account
(
username
,
fullname
,
reason
,
session
):
room
=
session
# Todo: Ravi's and Louis's code goes here
print
(
time
.
strftime
(
"
%m-%d-%Y_%H:%M:%S
"
)
+
'
\t
User
'
+
username
+
'
added to queue
'
)
send_msg
(
'
creating account
'
,
room
)
#socketio.emit("creating account", room=room)
print
(
username
)
subprocess
.
call
([
"
/opt/rabbitmq_agents/flask_producer.py
"
,
"
ohpc_account_create
"
,
username
])
#time.sleep(5)
print
(
time
.
strftime
(
"
%m-%d-%Y_%H:%M:%S
"
)
+
'
\t
Account successfully created for
'
+
username
)
send_msg
(
'
account ready
'
,
room
)
#socketio.emit('account ready', room=room)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment