Skip to content

Commit

Permalink
added get_remotes() status function to the api #633
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Letter committed Aug 24, 2016
1 parent 3d98bca commit 65b814c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/slycat/web/server/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def abspath(path):
dispatcher.connect("post-remote-browse", "/remotes/:sid/browse{path:.*}", slycat.web.server.handlers.post_remote_browse, conditions={"method" : ["POST"]})
dispatcher.connect("post-remote-videos", "/remotes/:sid/videos", slycat.web.server.handlers.post_remote_videos, conditions={"method" : ["POST"]})
dispatcher.connect("post-remotes", "/remotes", slycat.web.server.handlers.post_remotes, conditions={"method" : ["POST"]})
# dispatcher.connect("get-remotes", "/remotes/:hostname", slycat.web.server.handlers.get_remotes, conditions={"method" : ["GET"]})
dispatcher.connect("get-remotes", "/remotes/:hostname", slycat.web.server.handlers.get_remotes, conditions={"method" : ["GET"]})

dispatcher.connect("put-model-arrayset-array", "/models/:mid/arraysets/:aid/arrays/:array", slycat.web.server.handlers.put_model_arrayset_array, conditions={"method" : ["PUT"]})
dispatcher.connect("put-model-arrayset-data", "/models/:mid/arraysets/:aid/data", slycat.web.server.handlers.put_model_arrayset_data, conditions={"method" : ["PUT"]})
Expand Down
20 changes: 18 additions & 2 deletions packages/slycat/web/server/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1752,12 +1752,28 @@ def post_remotes():
database.save(session)
except Exception as e:
cherrypy.log.error("could not save session for remotes %s" % e)
#
return {"sid": sid}

@cherrypy.tools.json_out(on = True)
def get_remotes(hostname):
return {"status":True, "msg":""}
"""
Returns {status: True} if the hostname was found in the user's
session
:param hostname: connection host name
:return: {"status":status, "msg":msg}
"""
status = False
msg = "hostname session not found"
try:
database = slycat.web.server.database.couchdb.connect()
session = database.get("session", cherrypy.request.cookie["slycatauth"].value)
for session in session["sessions"]:
if session["hostname"] == hostname:
status = True
msg = "hostname session was found"
except Exception as e:
cherrypy.log.error("could not save session for remotes %s" % e)
return {"status":status, "msg":msg}

def delete_remote(sid):
slycat.web.server.remote.delete_session(sid)
Expand Down

0 comments on commit 65b814c

Please sign in to comment.