Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pyfs
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
pyfs
Commits
c5d09ac3
Commit
c5d09ac3
authored
Dec 19, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Docstrings and fixes for sftp server
parent
742ff4a6
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
45 additions
and
6 deletions
+45
-6
fs/commands/fsserve.py
+10
-0
fs/expose/http.py
+10
-0
fs/expose/sftp.py
+22
-6
fs/sftpfs.py
+3
-0
No files found.
fs/commands/fsserve.py
View file @
c5d09ac3
...
...
@@ -57,6 +57,16 @@ Serves the contents of PATH with one of a number of methods"""
elif
options
.
type
==
'sftp'
:
from
fs.expose.sftp
import
BaseSFTPServer
import
logging
log
=
logging
.
getLogger
(
'paramiko'
)
if
options
.
debug
:
log
.
setLevel
(
logging
.
DEBUG
)
elif
options
.
verbose
:
log
.
setLevel
(
logging
.
INFO
)
ch
=
logging
.
StreamHandler
()
ch
.
setLevel
(
logging
.
DEBUG
)
log
.
addHandler
(
ch
)
if
port
is
None
:
port
=
22
server
=
BaseSFTPServer
((
options
.
addr
,
port
),
fs
)
...
...
fs/expose/http.py
View file @
c5d09ac3
__all__
=
[
"serve_fs"
]
import
SimpleHTTPServer
import
SocketServer
from
fs.path
import
pathjoin
,
dirname
...
...
@@ -128,6 +130,14 @@ class FSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def
serve_fs
(
fs
,
address
=
''
,
port
=
8000
):
"""Serve an FS instance over http
:param fs: an FS object
:param address: IP address to serve on
:param port: port number
"""
def
Handler
(
request
,
client_address
,
server
):
return
FSHTTPRequestHandler
(
fs
,
request
,
client_address
,
server
)
...
...
fs/expose/sftp.py
View file @
c5d09ac3
...
...
@@ -37,6 +37,7 @@ from fs.path import *
from
fs.errors
import
*
from
fs.local_functools
import
wraps
from
fs.filelike
import
StringIO
from
fs.utils
import
isdir
# Default host key used by BaseSFTPServer
...
...
@@ -94,20 +95,35 @@ class SFTPServerInterface(paramiko.SFTPServerInterface):
path
=
path
.
decode
(
self
.
encoding
)
stats
=
[]
for
entry
in
self
.
fs
.
listdir
(
path
,
absolute
=
True
):
stats
.
append
(
self
.
stat
(
entry
))
stat
=
self
.
stat
(
entry
)
if
not
isinstance
(
stat
,
int
):
stats
.
append
(
stat
)
return
stats
@report_sftp_errors
def
stat
(
self
,
path
):
if
not
isinstance
(
path
,
unicode
):
path
=
path
.
decode
(
self
.
encoding
)
info
=
self
.
fs
.
getinfo
(
path
)
get
=
info
.
get
stat
=
paramiko
.
SFTPAttributes
()
stat
.
filename
=
basename
(
path
)
.
encode
(
self
.
encoding
)
stat
.
st_size
=
info
.
get
(
"size"
)
stat
.
st_atime
=
time
.
mktime
(
info
.
get
(
"accessed_time"
)
.
timetuple
())
stat
.
st_mtime
=
time
.
mktime
(
info
.
get
(
"modified_time"
)
.
timetuple
())
if
self
.
fs
.
isdir
(
path
):
if
'st_atime'
in
info
:
stat
.
st_atime
=
get
(
'st_atime'
)
elif
'accessed_time'
in
info
:
stat
.
st_atime
=
time
.
mktime
(
get
(
"accessed_time"
)
.
timetuple
())
if
'st_mtime'
in
info
:
stat
.
st_mtime
=
get
(
'st_mtime'
)
else
:
if
'modified_time'
in
info
:
stat
.
st_mtime
=
time
.
mktime
(
get
(
"modified_time"
)
.
timetuple
())
if
isdir
(
self
.
fs
,
path
,
info
):
stat
.
st_mode
=
0777
|
statinfo
.
S_IFDIR
else
:
stat
.
st_mode
=
0777
|
statinfo
.
S_IFREG
...
...
@@ -288,11 +304,11 @@ class BaseSFTPServer(sockserv.TCPServer,paramiko.ServerInterface):
return
paramiko
.
AUTH_FAILED
def
get_allowed_auths
(
self
,
username
):
"""Return list of allowed auth modes.
"""Return
string containing a comma separated
list of allowed auth modes.
The available modes are "node", "password" and "publickey".
"""
return
(
"none"
,)
return
"none"
# When called from the command-line, expose a TempFS for testing purposes
...
...
fs/sftpfs.py
View file @
c5d09ac3
...
...
@@ -153,6 +153,9 @@ class SFTPFS(FS):
self
.
_agent_auth
(
connection
,
username
)
if
not
connection
.
is_authenticated
():
connection
.
auth_none
(
''
)
if
not
connection
.
is_authenticated
():
connection
.
close
()
raise
RemoteConnectionError
(
'no auth'
)
...
...
Write
Preview
Markdown
is supported
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