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
098ac18c
Commit
098ac18c
authored
Nov 28, 2012
by
btimby
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some encoding mismatch between pyftpdlib (uses str internally) and pyfs (uses unicode).
parent
e92c9d12
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
+11
-2
fs/expose/ftp.py
+11
-2
No files found.
fs/expose/ftp.py
View file @
098ac18c
...
@@ -38,6 +38,8 @@ def decode_args(f):
...
@@ -38,6 +38,8 @@ def decode_args(f):
Decodes string arguments using the decoding defined on the method's class.
Decodes string arguments using the decoding defined on the method's class.
This decorator is for use on methods (functions which take a class or instance
This decorator is for use on methods (functions which take a class or instance
as the first parameter).
as the first parameter).
Pyftpdlib (as of 0.7.0) uses str internally, so this decoding is necessary.
"""
"""
@wraps
(
f
)
@wraps
(
f
)
def
wrapper
(
self
,
*
args
):
def
wrapper
(
self
,
*
args
):
...
@@ -97,17 +99,22 @@ class FTPFS(ftpserver.AbstractedFS):
...
@@ -97,17 +99,22 @@ class FTPFS(ftpserver.AbstractedFS):
def
open
(
self
,
path
,
mode
):
def
open
(
self
,
path
,
mode
):
return
self
.
fs
.
open
(
path
,
mode
)
return
self
.
fs
.
open
(
path
,
mode
)
@convert_fs_errors
def
chdir
(
self
,
path
):
def
chdir
(
self
,
path
):
# We dont' use the decorator here, we actually decode a version of the
# path for use with pyfs, but keep the original for use with pyftpdlib.
unipath
=
unicode
(
path
,
self
.
encoding
)
# TODO: can the following conditional checks be farmed out to the fs?
# TODO: can the following conditional checks be farmed out to the fs?
# If we don't raise an error here for files, then the FTP server will
# If we don't raise an error here for files, then the FTP server will
# happily allow the client to CWD into a file. We really only want to
# happily allow the client to CWD into a file. We really only want to
# allow that for directories.
# allow that for directories.
if
self
.
fs
.
isfile
(
path
):
if
self
.
fs
.
isfile
(
uni
path
):
raise
OSError
(
errno
.
ENOTDIR
,
'Not a directory'
)
raise
OSError
(
errno
.
ENOTDIR
,
'Not a directory'
)
# similarly, if we don't check for existence, the FTP server will allow
# similarly, if we don't check for existence, the FTP server will allow
# the client to CWD into a non-existent directory.
# the client to CWD into a non-existent directory.
if
not
self
.
fs
.
exists
(
path
):
if
not
self
.
fs
.
exists
(
uni
path
):
raise
OSError
(
errno
.
ENOENT
,
'Does not exist'
)
raise
OSError
(
errno
.
ENOENT
,
'Does not exist'
)
# We use the original path here, so we don't corrupt self._cwd
self
.
_cwd
=
self
.
ftp2fs
(
path
)
self
.
_cwd
=
self
.
ftp2fs
(
path
)
@convert_fs_errors
@convert_fs_errors
...
@@ -135,6 +142,8 @@ class FTPFS(ftpserver.AbstractedFS):
...
@@ -135,6 +142,8 @@ class FTPFS(ftpserver.AbstractedFS):
def
rename
(
self
,
src
,
dst
):
def
rename
(
self
,
src
,
dst
):
self
.
fs
.
rename
(
src
,
dst
)
self
.
fs
.
rename
(
src
,
dst
)
@convert_fs_errors
@decode_args
def
chmod
(
self
,
path
,
mode
):
def
chmod
(
self
,
path
,
mode
):
return
return
...
...
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