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
b3f5828b
Commit
b3f5828b
authored
Apr 19, 2012
by
btimby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Just whitespace and PEP8 changes.
parent
73aecc22
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
15 deletions
+31
-15
fs/expose/sftp.py
+31
-15
No files found.
fs/expose/sftp.py
View file @
b3f5828b
...
@@ -44,7 +44,23 @@ from fs.utils import isdir
...
@@ -44,7 +44,23 @@ from fs.utils import isdir
# Default host key used by BaseSFTPServer
# Default host key used by BaseSFTPServer
#
#
DEFAULT_HOST_KEY
=
paramiko
.
RSAKey
.
from_private_key
(
StringIO
(
"-----BEGIN RSA PRIVATE KEY-----
\n
MIICXgIBAAKCAIEAl7sAF0x2O/HwLhG68b1uG8KHSOTqe3Cdlj5i/1RhO7E2BJ4B
\n
3jhKYDYtupRnMFbpu7fb21A24w3Y3W5gXzywBxR6dP2HgiSDVecoDg2uSYPjnlDk
\n
HrRuviSBG3XpJ/awn1DObxRIvJP4/sCqcMY8Ro/3qfmid5WmMpdCZ3EBeC0CAwEA
\n
AQKCAIBSGefUs5UOnr190C49/GiGMN6PPP78SFWdJKjgzEHI0P0PxofwPLlSEj7w
\n
RLkJWR4kazpWE7N/bNC6EK2pGueMN9Ag2GxdIRC5r1y8pdYbAkuFFwq9Tqa6j5B0
\n
GkkwEhrcFNBGx8UfzHESXe/uE16F+e8l6xBMcXLMJVo9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U6L9M3JZ1VkabRuWwKNuEzEHNK8cLbRl
\n
"
\
"TyH0mceWXcsCQQDLDEuWcOeoDteEpNhVJFkXJJfwZ4Rlxu42MDsQQ/paJCjt2ONU
\n
"
\
"WBn/P6iYDTvxrt/8+CtLfYc+QQkrTnKn3cLnAkEAk3ixXR0h46Rj4j/9uSOfyyow
\n
"
\
"qHQunlZ50hvNz8GAm4TU7v82m96449nFZtFObC69SLx/VsboTPsUh96idgRrBQJA
\n
"
\
"QBfGeFt1VGAy+YTLYLzTfnGnoFQcv7+2i9ZXnn/Gs9N8M+/lekdBFYgzoKN0y4pG
\n
"
\
"2+Q+Tlr2aNlAmrHtkT13+wJAJVgZATPI5X3UO0Wdf24f/w9+OY+QxKGl86tTQXzE
\n
"
\
"4bwvYtUGufMIHiNeWP66i6fYCucXCMYtx6Xgu2hpdZZpFw==
\n
"
\
"-----END RSA PRIVATE KEY-----
\n
"
))
def
report_sftp_errors
(
func
):
def
report_sftp_errors
(
func
):
...
@@ -55,8 +71,8 @@ def report_sftp_errors(func):
...
@@ -55,8 +71,8 @@ def report_sftp_errors(func):
"""
"""
@wraps
(
func
)
@wraps
(
func
)
def
wrapper
(
*
args
,
**
kwds
):
def
wrapper
(
*
args
,
**
kwds
):
try
:
try
:
return
func
(
*
args
,
**
kwds
)
return
func
(
*
args
,
**
kwds
)
except
ResourceNotFoundError
,
e
:
except
ResourceNotFoundError
,
e
:
return
paramiko
.
SFTP_NO_SUCH_FILE
return
paramiko
.
SFTP_NO_SUCH_FILE
except
UnsupportedError
,
e
:
except
UnsupportedError
,
e
:
...
@@ -85,7 +101,7 @@ class SFTPServerInterface(paramiko.SFTPServerInterface):
...
@@ -85,7 +101,7 @@ class SFTPServerInterface(paramiko.SFTPServerInterface):
if
encoding
is
None
:
if
encoding
is
None
:
encoding
=
"utf8"
encoding
=
"utf8"
self
.
encoding
=
encoding
self
.
encoding
=
encoding
super
(
SFTPServerInterface
,
self
)
.
__init__
(
server
,
*
args
,
**
kwds
)
super
(
SFTPServerInterface
,
self
)
.
__init__
(
server
,
*
args
,
**
kwds
)
@report_sftp_errors
@report_sftp_errors
def
open
(
self
,
path
,
flags
,
attr
):
def
open
(
self
,
path
,
flags
,
attr
):
...
@@ -96,10 +112,10 @@ class SFTPServerInterface(paramiko.SFTPServerInterface):
...
@@ -96,10 +112,10 @@ class SFTPServerInterface(paramiko.SFTPServerInterface):
if
not
isinstance
(
path
,
unicode
):
if
not
isinstance
(
path
,
unicode
):
path
=
path
.
decode
(
self
.
encoding
)
path
=
path
.
decode
(
self
.
encoding
)
stats
=
[]
stats
=
[]
for
entry
in
self
.
fs
.
listdir
(
path
,
absolute
=
True
):
for
entry
in
self
.
fs
.
listdir
(
path
,
absolute
=
True
):
stat
=
self
.
stat
(
entry
)
stat
=
self
.
stat
(
entry
)
if
not
isinstance
(
stat
,
int
):
if
not
isinstance
(
stat
,
int
):
stats
.
append
(
stat
)
stats
.
append
(
stat
)
return
stats
return
stats
@report_sftp_errors
@report_sftp_errors
...
@@ -109,26 +125,26 @@ class SFTPServerInterface(paramiko.SFTPServerInterface):
...
@@ -109,26 +125,26 @@ class SFTPServerInterface(paramiko.SFTPServerInterface):
info
=
self
.
fs
.
getinfo
(
path
)
info
=
self
.
fs
.
getinfo
(
path
)
get
=
info
.
get
get
=
info
.
get
stat
=
paramiko
.
SFTPAttributes
()
stat
=
paramiko
.
SFTPAttributes
()
stat
.
filename
=
basename
(
path
)
.
encode
(
self
.
encoding
)
stat
.
filename
=
basename
(
path
)
.
encode
(
self
.
encoding
)
stat
.
st_size
=
info
.
get
(
"size"
)
stat
.
st_size
=
info
.
get
(
"size"
)
if
'st_atime'
in
info
:
if
'st_atime'
in
info
:
stat
.
st_atime
=
get
(
'st_atime'
)
stat
.
st_atime
=
get
(
'st_atime'
)
elif
'accessed_time'
in
info
:
elif
'accessed_time'
in
info
:
stat
.
st_atime
=
time
.
mktime
(
get
(
"accessed_time"
)
.
timetuple
())
stat
.
st_atime
=
time
.
mktime
(
get
(
"accessed_time"
)
.
timetuple
())
if
'st_mtime'
in
info
:
if
'st_mtime'
in
info
:
stat
.
st_mtime
=
get
(
'st_mtime'
)
stat
.
st_mtime
=
get
(
'st_mtime'
)
else
:
else
:
if
'modified_time'
in
info
:
if
'modified_time'
in
info
:
stat
.
st_mtime
=
time
.
mktime
(
get
(
"modified_time"
)
.
timetuple
())
stat
.
st_mtime
=
time
.
mktime
(
get
(
"modified_time"
)
.
timetuple
())
if
isdir
(
self
.
fs
,
path
,
info
):
if
isdir
(
self
.
fs
,
path
,
info
):
stat
.
st_mode
=
0777
|
statinfo
.
S_IFDIR
stat
.
st_mode
=
0777
|
statinfo
.
S_IFDIR
else
:
else
:
stat
.
st_mode
=
0777
|
statinfo
.
S_IFREG
stat
.
st_mode
=
0777
|
statinfo
.
S_IFREG
return
stat
return
stat
def
lstat
(
self
,
path
):
def
lstat
(
self
,
path
):
...
@@ -155,7 +171,7 @@ class SFTPServerInterface(paramiko.SFTPServerInterface):
...
@@ -155,7 +171,7 @@ class SFTPServerInterface(paramiko.SFTPServerInterface):
@report_sftp_errors
@report_sftp_errors
def
mkdir
(
self
,
path
,
attr
):
def
mkdir
(
self
,
path
,
attr
):
if
not
isinstance
(
path
,
unicode
):
if
not
isinstance
(
path
,
unicode
):
path
=
path
.
decode
(
self
.
encoding
)
path
=
path
.
decode
(
self
.
encoding
)
self
.
fs
.
makedir
(
path
)
self
.
fs
.
makedir
(
path
)
return
paramiko
.
SFTP_OK
return
paramiko
.
SFTP_OK
...
...
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