Skip to content

Commit

Permalink
update get_remote_file() to use user session sessions for host connec…
Browse files Browse the repository at this point in the history
…tions #633
  • Loading branch information
Matthew Letter committed Aug 24, 2016
1 parent b334929 commit 85785eb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 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 @@ -106,7 +106,7 @@ def abspath(path):
dispatcher.connect("get-projects", "/projects", slycat.web.server.handlers.get_projects, conditions={"method" : ["GET"]})

#TODO: scrub sid
dispatcher.connect("get-remote-file", "/remotes/:sid/file{path:.*}", slycat.web.server.handlers.get_remote_file, conditions={"method" : ["GET"]})
dispatcher.connect("get-remote-file", "/remotes/:hostname/file{path:.*}", slycat.web.server.handlers.get_remote_file, conditions={"method" : ["GET"]})
dispatcher.connect("get-remote-image", "/remotes/:hostname/image{path:.*}", slycat.web.server.handlers.get_remote_image, conditions={"method" : ["GET"]})
dispatcher.connect("get-remote-video", "/remotes/:sid/videos/:vsid", slycat.web.server.handlers.get_remote_video, conditions={"method" : ["GET"]})
dispatcher.connect("get-remote-video-status", "/remotes/:sid/videos/:vsid/status", slycat.web.server.handlers.get_remote_video_status, conditions={"method" : ["GET"]})
Expand Down
15 changes: 12 additions & 3 deletions packages/slycat/web/server/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1845,15 +1845,24 @@ def post_remote_browse(sid, path):
with slycat.web.server.remote.get_session(sid) as session:
return session.browse(path, file_reject, file_allow, directory_reject, directory_allow)

def get_remote_file(sid, path, **kwargs):
def get_remote_file(hostname, path, **kwargs):
"""
Given a hostname and file path returns the file given
by the path
:param hostname: connection host name
:param path: path to file
:param kwargs:
:return:
"""
sid = get_sid(hostname)
with slycat.web.server.remote.get_session(sid) as session:
return session.get_file(path, **kwargs)

def get_remote_image(hostname, path, **kwargs):
"""
given a hostanme and image path returns the image given
Given a hostname and image path returns the image given
by the path
:param hostname: connection name
:param hostname: connection host name
:param path: path to image
:param kwargs:
:return:
Expand Down

0 comments on commit 85785eb

Please sign in to comment.