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
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
17 additions
and
53 deletions
+17
-53
fs/commands/fsls.py
+0
-0
fs/commands/runner.py
+0
-0
fs/remote.py
+1
-14
fs/rpcfs.py
+2
-2
fs/sftpfs.py
+3
-33
fs/tests/__init__.py
+3
-1
fs/tests/test_expose.py
+3
-0
fs/tests/test_remote.py
+3
-1
fs/utils.py
+2
-2
No files found.
fs/commands/fsls.py
View file @
a5ffbc28
fs/commands/runner.py
View file @
a5ffbc28
fs/remote.py
View file @
a5ffbc28
...
@@ -253,21 +253,7 @@ class RemoteFileBuffer(FileWrapper):
...
@@ -253,21 +253,7 @@ class RemoteFileBuffer(FileWrapper):
if
"w"
in
self
.
mode
or
"a"
in
self
.
mode
or
"+"
in
self
.
mode
:
if
"w"
in
self
.
mode
or
"a"
in
self
.
mode
or
"+"
in
self
.
mode
:
pos
=
self
.
wrapped_file
.
tell
()
pos
=
self
.
wrapped_file
.
tell
()
self
.
wrapped_file
.
seek
(
0
)
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
)
self
.
wrapped_file
.
seek
(
pos
)
def
close
(
self
):
def
close
(
self
):
...
@@ -345,6 +331,7 @@ class ConnectionManagerFS(LazyFS):
...
@@ -345,6 +331,7 @@ class ConnectionManagerFS(LazyFS):
if
not
self
.
_poll_thread
:
if
not
self
.
_poll_thread
:
target
=
self
.
_poll_connection
target
=
self
.
_poll_connection
self
.
_poll_thread
=
threading
.
Thread
(
target
=
target
)
self
.
_poll_thread
=
threading
.
Thread
(
target
=
target
)
self
.
_poll_thread
.
daemon
=
True
self
.
_poll_thread
.
start
()
self
.
_poll_thread
.
start
()
self
.
_connection_cond
.
wait
(
timeout
)
self
.
_connection_cond
.
wait
(
timeout
)
finally
:
finally
:
...
...
fs/rpcfs.py
View file @
a5ffbc28
...
@@ -24,8 +24,8 @@ def re_raise_faults(func):
...
@@ -24,8 +24,8 @@ def re_raise_faults(func):
try
:
try
:
return
func
(
*
args
,
**
kwds
)
return
func
(
*
args
,
**
kwds
)
except
xmlrpclib
.
Fault
,
f
:
except
xmlrpclib
.
Fault
,
f
:
import
traceback
#
import traceback
traceback
.
print_exc
()
#
traceback.print_exc()
# Make sure it's in a form we can handle
# Make sure it's in a form we can handle
bits
=
f
.
faultString
.
split
(
" "
)
bits
=
f
.
faultString
.
split
(
" "
)
if
bits
[
0
]
not
in
[
"<type"
,
"<class"
]:
if
bits
[
0
]
not
in
[
"<type"
,
"<class"
]:
...
...
fs/sftpfs.py
View file @
a5ffbc28
...
@@ -103,50 +103,20 @@ class SFTPFS(FS):
...
@@ -103,50 +103,20 @@ class SFTPFS(FS):
except
ValueError
:
except
ValueError
:
pass
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
):
if
isinstance
(
connection
,
paramiko
.
Channel
):
self
.
_transport
=
None
self
.
_transport
=
None
self
.
_client
=
paramiko
.
SFTPClient
(
connection
)
self
.
_client
=
paramiko
.
SFTPClient
(
connection
)
else
:
else
:
if
not
isinstance
(
connection
,
paramiko
.
Transport
):
if
not
isinstance
(
connection
,
paramiko
.
Transport
):
connection
=
paramiko
.
Transport
(
connection
)
connection
=
paramiko
.
Transport
(
connection
)
self
.
_owns_transport
=
True
self
.
_owns_transport
=
True
try
:
if
not
connection
.
is_authenticated
():
if
not
connection
.
is_authenticated
():
connection
.
connect
(
**
credentials
)
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'
)
self
.
_transport
=
connection
self
.
_transport
=
connection
self
.
root_path
=
abspath
(
normpath
(
root_path
))
@classmethod
@classmethod
def
_agent_auth
(
cls
,
transport
,
username
):
def
_agent_auth
(
cls
,
transport
,
username
):
...
...
fs/tests/__init__.py
View file @
a5ffbc28
...
@@ -761,7 +761,9 @@ class ThreadingTestCases:
...
@@ -761,7 +761,9 @@ class ThreadingTestCases:
func
()
func
()
except
Exception
:
except
Exception
:
errors
.
append
(
sys
.
exc_info
())
errors
.
append
(
sys
.
exc_info
())
return
threading
.
Thread
(
target
=
runThread
)
thread
=
threading
.
Thread
(
target
=
runThread
)
thread
.
daemon
=
True
return
thread
def
_runThreads
(
self
,
*
funcs
):
def
_runThreads
(
self
,
*
funcs
):
check_interval
=
sys
.
getcheckinterval
()
check_interval
=
sys
.
getcheckinterval
()
...
...
fs/tests/test_expose.py
View file @
a5ffbc28
...
@@ -197,3 +197,5 @@ if dokan.is_available:
...
@@ -197,3 +197,5 @@ if dokan.is_available:
self
.
mount_proc
.
terminate
()
self
.
mount_proc
.
terminate
()
self
.
temp_fs
.
close
()
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):
...
@@ -229,7 +229,7 @@ class TestCacheFS(unittest.TestCase,FSTestCases,ThreadingTestCases):
sys
.
setcheckinterval
(
self
.
_check_interval
)
sys
.
setcheckinterval
(
self
.
_check_interval
)
class
TestConnectionManagerFS
(
unittest
.
TestCase
,
FSTestCases
,
ThreadingTestCases
):
class
TestConnectionManagerFS
(
unittest
.
TestCase
,
FSTestCases
):
#
,ThreadingTestCases):
"""Test simple operation of ConnectionManagerFS"""
"""Test simple operation of ConnectionManagerFS"""
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -255,6 +255,7 @@ class DisconnectingFS(WrapFS):
...
@@ -255,6 +255,7 @@ class DisconnectingFS(WrapFS):
if
random
.
choice
([
True
,
False
]):
if
random
.
choice
([
True
,
False
]):
raise
RemoteConnectionError
(
""
)
raise
RemoteConnectionError
(
""
)
self
.
_bounce_thread
=
threading
.
Thread
(
target
=
self
.
_bounce
)
self
.
_bounce_thread
=
threading
.
Thread
(
target
=
self
.
_bounce
)
self
.
_bounce_thread
.
daemon
=
True
self
.
_bounce_thread
.
start
()
self
.
_bounce_thread
.
start
()
def
__getstate__
(
self
):
def
__getstate__
(
self
):
...
@@ -265,6 +266,7 @@ class DisconnectingFS(WrapFS):
...
@@ -265,6 +266,7 @@ class DisconnectingFS(WrapFS):
def
__setstate__
(
self
,
state
):
def
__setstate__
(
self
,
state
):
super
(
DisconnectingFS
,
self
)
.
__setstate__
(
state
)
super
(
DisconnectingFS
,
self
)
.
__setstate__
(
state
)
self
.
_bounce_thread
=
threading
.
Thread
(
target
=
self
.
_bounce
)
self
.
_bounce_thread
=
threading
.
Thread
(
target
=
self
.
_bounce
)
self
.
_bounce_thread
.
daemon
=
True
self
.
_bounce_thread
.
start
()
self
.
_bounce_thread
.
start
()
def
_bounce
(
self
):
def
_bounce
(
self
):
...
...
fs/utils.py
View file @
a5ffbc28
...
@@ -168,7 +168,7 @@ def copystructure(src_fs, dst_fs):
...
@@ -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
)
dst_fs
.
makedir
(
path
,
allow_recreate
=
True
)
...
@@ -291,7 +291,7 @@ def find_duplicates(fs,
...
@@ -291,7 +291,7 @@ def find_duplicates(fs,
return
return
def
identical
(
p1
,
p2
):
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
f1
,
f2
=
None
,
None
try
:
try
:
f1
=
fs
.
open
(
p1
,
'rb'
)
f1
=
fs
.
open
(
p1
,
'rb'
)
...
...
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