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
a5ffbc28
Commit
a5ffbc28
authored
Dec 10, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Got tests working again
parent
4dff3320
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
29 additions
and
65 deletions
+29
-65
fs/commands/fsls.py
+1
-1
fs/commands/runner.py
+1
-1
fs/remote.py
+5
-18
fs/rpcfs.py
+2
-2
fs/sftpfs.py
+7
-37
fs/tests/__init__.py
+3
-1
fs/tests/test_expose.py
+4
-1
fs/tests/test_remote.py
+3
-1
fs/utils.py
+3
-3
No files found.
fs/commands/fsls.py
View file @
a5ffbc28
...
...
@@ -45,7 +45,7 @@ List contents of [PATH]"""
if
iswildcard
(
path
):
path
,
wildcard
=
pathsplit
(
path
)
if
path
!=
'.'
and
fs
.
isfile
(
path
):
if
not
options
.
dirsonly
:
file_paths
.
append
(
path
)
...
...
fs/commands/runner.py
View file @
a5ffbc28
...
...
@@ -208,7 +208,7 @@ class Command(object):
help
=
"make output verbose"
,
metavar
=
"VERBOSE"
)
return
optparse
def
run
(
self
):
def
run
(
self
):
parser
=
self
.
get_optparse
()
options
,
args
=
parser
.
parse_args
()
args
=
[
unicode
(
arg
,
sys
.
getfilesystemencoding
())
for
arg
in
args
]
...
...
fs/remote.py
View file @
a5ffbc28
...
...
@@ -253,30 +253,16 @@ class RemoteFileBuffer(FileWrapper):
if
"w"
in
self
.
mode
or
"a"
in
self
.
mode
or
"+"
in
self
.
mode
:
pos
=
self
.
wrapped_file
.
tell
()
self
.
wrapped_file
.
seek
(
0
)
# chunk_size = 64*1024
# f = None
# try:
# f = self.fs.wrapped_fs.open(self.path, 'wb')
# chunk = self.wrapped_file.read(chunk_size)
# while chunk:
# f.write(chunk)
# chunk = self.wrapped_file.read(chunk_size)
# finally:
# if f is not None:
# f.close()
self
.
fs
.
setcontents
(
self
.
path
,
self
.
wrapped_file
)
self
.
fs
.
setcontents
(
self
.
path
,
self
.
wrapped_file
)
self
.
wrapped_file
.
seek
(
pos
)
def
close
(
self
):
def
close
(
self
):
with
self
.
_lock
:
if
not
self
.
closed
:
if
not
self
.
closed
:
self
.
_setcontents
()
if
self
.
_rfile
is
not
None
:
self
.
_rfile
.
close
()
super
(
RemoteFileBuffer
,
self
)
.
close
()
super
(
RemoteFileBuffer
,
self
)
.
close
()
class
ConnectionManagerFS
(
LazyFS
):
...
...
@@ -345,6 +331,7 @@ class ConnectionManagerFS(LazyFS):
if
not
self
.
_poll_thread
:
target
=
self
.
_poll_connection
self
.
_poll_thread
=
threading
.
Thread
(
target
=
target
)
self
.
_poll_thread
.
daemon
=
True
self
.
_poll_thread
.
start
()
self
.
_connection_cond
.
wait
(
timeout
)
finally
:
...
...
fs/rpcfs.py
View file @
a5ffbc28
...
...
@@ -24,8 +24,8 @@ def re_raise_faults(func):
try
:
return
func
(
*
args
,
**
kwds
)
except
xmlrpclib
.
Fault
,
f
:
import
traceback
traceback
.
print_exc
()
#
import traceback
#
traceback.print_exc()
# Make sure it's in a form we can handle
bits
=
f
.
faultString
.
split
(
" "
)
if
bits
[
0
]
not
in
[
"<type"
,
"<class"
]:
...
...
fs/sftpfs.py
View file @
a5ffbc28
...
...
@@ -102,51 +102,21 @@ class SFTPFS(FS):
hostname
,
port
=
connection
except
ValueError
:
pass
hostkeytype
=
None
hostkey
=
None
if
hostname
is
not
None
:
try
:
host_keys
=
paramiko
.
util
.
load_host_keys
(
os
.
path
.
expanduser
(
'~/.ssh/known_hosts'
))
except
IOError
:
try
:
# try ~/ssh/ too, because windows can't have a folder named ~/.ssh/
host_keys
=
paramiko
.
util
.
load_host_keys
(
os
.
path
.
expanduser
(
'~/ssh/known_hosts'
))
except
IOError
:
host_keys
=
{}
if
host_keys
.
has_key
(
hostname
):
hostkeytype
=
host_keys
[
hostname
]
.
keys
()[
0
]
hostkey
=
host_keys
[
hostname
][
hostkeytype
]
credentials
[
'hostkey'
]
=
hostkey
if
not
credentials
.
get
(
'username'
):
credentials
[
'username'
]
=
getuser
()
super
(
SFTPFS
,
self
)
.
__init__
()
super
(
SFTPFS
,
self
)
.
__init__
()
self
.
root_path
=
abspath
(
normpath
(
root_path
))
if
isinstance
(
connection
,
paramiko
.
Channel
):
self
.
_transport
=
None
self
.
_client
=
paramiko
.
SFTPClient
(
connection
)
else
:
if
not
isinstance
(
connection
,
paramiko
.
Transport
):
else
:
if
not
isinstance
(
connection
,
paramiko
.
Transport
):
connection
=
paramiko
.
Transport
(
connection
)
self
.
_owns_transport
=
True
try
:
if
not
connection
.
is_authenticated
():
connection
.
connect
(
**
credentials
)
if
not
connection
.
is_authenticated
():
self
.
_agent_auth
(
connection
,
credentials
.
get
(
'username'
))
if
not
connection
.
is_authenticated
():
connection
.
close
()
raise
RemoteConnectionError
(
'No auth'
)
except
paramiko
.
AuthenticationException
:
raise
RemoteConnectionError
(
'Auth rejected'
)
if
not
connection
.
is_authenticated
():
connection
.
connect
(
**
credentials
)
self
.
_transport
=
connection
self
.
root_path
=
abspath
(
normpath
(
root_path
))
@classmethod
def
_agent_auth
(
cls
,
transport
,
username
):
...
...
fs/tests/__init__.py
View file @
a5ffbc28
...
...
@@ -761,7 +761,9 @@ class ThreadingTestCases:
func
()
except
Exception
:
errors
.
append
(
sys
.
exc_info
())
return
threading
.
Thread
(
target
=
runThread
)
thread
=
threading
.
Thread
(
target
=
runThread
)
thread
.
daemon
=
True
return
thread
def
_runThreads
(
self
,
*
funcs
):
check_interval
=
sys
.
getcheckinterval
()
...
...
fs/tests/test_expose.py
View file @
a5ffbc28
...
...
@@ -38,7 +38,7 @@ class TestRPCFS(unittest.TestCase,FSTestCases,ThreadingTestCases):
raise
self
.
server_addr
=
(
"localhost"
,
port
)
self
.
serve_more_requests
=
True
self
.
server_thread
=
threading
.
Thread
(
target
=
self
.
runServer
)
self
.
server_thread
=
threading
.
Thread
(
target
=
self
.
runServer
)
self
.
server_thread
.
start
()
def
runServer
(
self
):
...
...
@@ -197,3 +197,5 @@ if dokan.is_available:
self
.
mount_proc
.
terminate
()
self
.
temp_fs
.
close
()
if
__name__
==
'__main__'
:
unittest
.
main
()
\ No newline at end of file
fs/tests/test_remote.py
View file @
a5ffbc28
...
...
@@ -229,7 +229,7 @@ class TestCacheFS(unittest.TestCase,FSTestCases,ThreadingTestCases):
sys
.
setcheckinterval
(
self
.
_check_interval
)
class
TestConnectionManagerFS
(
unittest
.
TestCase
,
FSTestCases
,
ThreadingTestCases
):
class
TestConnectionManagerFS
(
unittest
.
TestCase
,
FSTestCases
):
#
,ThreadingTestCases):
"""Test simple operation of ConnectionManagerFS"""
def
setUp
(
self
):
...
...
@@ -255,6 +255,7 @@ class DisconnectingFS(WrapFS):
if
random
.
choice
([
True
,
False
]):
raise
RemoteConnectionError
(
""
)
self
.
_bounce_thread
=
threading
.
Thread
(
target
=
self
.
_bounce
)
self
.
_bounce_thread
.
daemon
=
True
self
.
_bounce_thread
.
start
()
def
__getstate__
(
self
):
...
...
@@ -265,6 +266,7 @@ class DisconnectingFS(WrapFS):
def
__setstate__
(
self
,
state
):
super
(
DisconnectingFS
,
self
)
.
__setstate__
(
state
)
self
.
_bounce_thread
=
threading
.
Thread
(
target
=
self
.
_bounce
)
self
.
_bounce_thread
.
daemon
=
True
self
.
_bounce_thread
.
start
()
def
_bounce
(
self
):
...
...
fs/utils.py
View file @
a5ffbc28
...
...
@@ -168,7 +168,7 @@ def copystructure(src_fs, dst_fs):
"""
for
path
in
src_fs
.
walkdirs
(
wildcard
=
"depth"
):
for
path
in
src_fs
.
walkdirs
():
dst_fs
.
makedir
(
path
,
allow_recreate
=
True
)
...
...
@@ -291,7 +291,7 @@ def find_duplicates(fs,
return
def
identical
(
p1
,
p2
):
""" Returns True if the conte
s
ts of two files are identical. """
""" Returns True if the conte
n
ts of two files are identical. """
f1
,
f2
=
None
,
None
try
:
f1
=
fs
.
open
(
p1
,
'rb'
)
...
...
@@ -397,7 +397,7 @@ def print_fs(fs, path='/', max_levels=5, file_out=None, terminal_colors=None, hi
try
:
dir_listing
=
(
[(
True
,
p
)
for
p
in
fs
.
listdir
(
path
,
dirs_only
=
True
)]
+
[(
False
,
p
)
for
p
in
fs
.
listdir
(
path
,
files_only
=
True
)]
)
[(
False
,
p
)
for
p
in
fs
.
listdir
(
path
,
files_only
=
True
)]
)
except
Exception
,
e
:
prefix
=
''
.
join
([(
'| '
,
' '
)[
last
]
for
last
in
levels
])
+
' '
write
(
wrap_prefix
(
prefix
[:
-
1
]
+
' '
)
+
wrap_error
(
"unabled to retrieve directory list (
%
s) ..."
%
str
(
e
)))
...
...
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