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
29cab8cf
Commit
29cab8cf
authored
Oct 01, 2010
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FTPFS: raise ResourceInvalidError when open() is called on a directory
parent
081ea835
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
fs/ftpfs.py
+2
-0
fs/tests/__init__.py
+12
-3
No files found.
fs/ftpfs.py
View file @
29cab8cf
...
@@ -956,6 +956,8 @@ class FTPFS(FS):
...
@@ -956,6 +956,8 @@ class FTPFS(FS):
@ftperrors
@ftperrors
def
open
(
self
,
path
,
mode
=
'r'
):
def
open
(
self
,
path
,
mode
=
'r'
):
mode
=
mode
.
lower
()
mode
=
mode
.
lower
()
if
self
.
isdir
(
path
):
raise
ResourceInvalidError
(
path
)
if
'r'
in
mode
:
if
'r'
in
mode
:
if
not
self
.
isfile
(
path
):
if
not
self
.
isfile
(
path
):
raise
ResourceNotFoundError
(
path
)
raise
ResourceNotFoundError
(
path
)
...
...
fs/tests/__init__.py
View file @
29cab8cf
...
@@ -21,6 +21,7 @@ import os, os.path
...
@@ -21,6 +21,7 @@ import os, os.path
import
pickle
import
pickle
import
random
import
random
import
copy
import
copy
from
StringIO
import
StringIO
import
time
import
time
try
:
try
:
...
@@ -75,7 +76,7 @@ class FSTestCases(object):
...
@@ -75,7 +76,7 @@ class FSTestCases(object):
except
ResourceInvalidError
:
except
ResourceInvalidError
:
pass
pass
except
Exception
:
except
Exception
:
ecls
=
sys
.
exc_info
[
0
]
ecls
=
sys
.
exc_info
()
[
0
]
assert
False
,
"
%
s raised instead of ResourceInvalidError"
%
(
ecls
,)
assert
False
,
"
%
s raised instead of ResourceInvalidError"
%
(
ecls
,)
else
:
else
:
f
.
close
()
f
.
close
()
...
@@ -98,6 +99,14 @@ class FSTestCases(object):
...
@@ -98,6 +99,14 @@ class FSTestCases(object):
self
.
assertEquals
(
f
.
read
(),
"test file overwrite"
)
self
.
assertEquals
(
f
.
read
(),
"test file overwrite"
)
f
.
close
()
f
.
close
()
def
test_setcontents
(
self
):
# setcontents() should accept both a string...
self
.
fs
.
setcontents
(
"hello"
,
"world"
)
self
.
assertEquals
(
self
.
fs
.
getcontents
(
"hello"
),
"world"
)
# ...and a file-like object
self
.
fs
.
setcontents
(
"hello"
,
StringIO
(
"to you, good sir!"
))
self
.
assertEquals
(
self
.
fs
.
getcontents
(
"hello"
),
"to you, good sir!"
)
def
test_isdir_isfile
(
self
):
def
test_isdir_isfile
(
self
):
self
.
assertFalse
(
self
.
fs
.
exists
(
"dir1"
))
self
.
assertFalse
(
self
.
fs
.
exists
(
"dir1"
))
self
.
assertFalse
(
self
.
fs
.
isdir
(
"dir1"
))
self
.
assertFalse
(
self
.
fs
.
isdir
(
"dir1"
))
...
@@ -703,7 +712,7 @@ class ThreadingTestCases:
...
@@ -703,7 +712,7 @@ class ThreadingTestCases:
finally
:
finally
:
sys
.
setcheckinterval
(
check_interval
)
sys
.
setcheckinterval
(
check_interval
)
def
test_setcontents
(
self
):
def
test_setcontents
_threaded
(
self
):
def
setcontents
(
name
,
contents
):
def
setcontents
(
name
,
contents
):
f
=
self
.
fs
.
open
(
name
,
"w"
)
f
=
self
.
fs
.
open
(
name
,
"w"
)
self
.
_yield
()
self
.
_yield
()
...
@@ -722,7 +731,7 @@ class ThreadingTestCases:
...
@@ -722,7 +731,7 @@ class ThreadingTestCases:
self
.
assertEquals
(
self
.
fs
.
getcontents
(
"thread2.txt"
),
c
)
self
.
assertEquals
(
self
.
fs
.
getcontents
(
"thread2.txt"
),
c
)
self
.
_runThreads
(
thread1
,
thread2
)
self
.
_runThreads
(
thread1
,
thread2
)
def
test_setcontents_samefile
(
self
):
def
test_setcontents_
threaded_
samefile
(
self
):
def
setcontents
(
name
,
contents
):
def
setcontents
(
name
,
contents
):
f
=
self
.
fs
.
open
(
name
,
"w"
)
f
=
self
.
fs
.
open
(
name
,
"w"
)
self
.
_yield
()
self
.
_yield
()
...
...
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