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
f1f224c1
Commit
f1f224c1
authored
Dec 07, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for zip opener
parent
40c775ea
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
22 deletions
+30
-22
fs/commands/fscp.py
+5
-6
fs/commands/runner.py
+7
-5
fs/opener.py
+12
-6
fs/rpcfs.py
+2
-0
fs/zipfs.py
+4
-5
No files found.
fs/commands/fscp.py
View file @
f1f224c1
...
...
@@ -29,7 +29,7 @@ class FileOpThread(threading.Thread):
except
queue
.
Empty
:
continue
try
:
if
path_type
==
FS
Copy
.
DIR
:
if
path_type
==
FS
cp
.
DIR
:
self
.
dest_fs
.
makedir
(
path
,
recursive
=
True
,
allow_recreate
=
True
)
else
:
self
.
action
(
fs
,
path
,
self
.
dest_fs
,
dest_path
,
overwrite
=
True
)
...
...
@@ -43,7 +43,7 @@ class FileOpThread(threading.Thread):
except
Exception
,
e
:
self
.
on_error
(
e
)
class
FS
Copy
(
Command
):
class
FS
cp
(
Command
):
DIR
,
FILE
=
0
,
1
...
...
@@ -54,7 +54,7 @@ Copy SOURCE to DESTINATION"""
return
copyfile
def
get_optparse
(
self
):
optparse
=
super
(
FS
Copy
,
self
)
.
get_optparse
()
optparse
=
super
(
FS
cp
,
self
)
.
get_optparse
()
optparse
.
add_option
(
'-p'
,
'--progress'
,
dest
=
'progress'
,
action
=
"store_true"
,
default
=
False
,
help
=
"show progress"
,
metavar
=
"PROGRESS"
)
optparse
.
add_option
(
'-t'
,
'--threads'
,
dest
=
'threads'
,
action
=
"store"
,
default
=
1
,
...
...
@@ -101,6 +101,7 @@ Copy SOURCE to DESTINATION"""
self
.
root_dirs
.
append
((
src_fs
,
src_path
))
src_sub_fs
=
src_fs
.
opendir
(
src_path
)
for
dir_path
,
file_paths
in
src_sub_fs
.
walk
():
if
dir_path
not
in
(
''
,
'/'
):
copy_fs_paths
.
append
((
self
.
DIR
,
src_sub_fs
,
dir_path
,
dir_path
))
sub_fs
=
src_sub_fs
.
opendir
(
dir_path
)
for
file_path
in
file_paths
:
...
...
@@ -112,7 +113,6 @@ Copy SOURCE to DESTINATION"""
self
.
error
(
'
%
s is not a file or directory
\n
'
%
src_path
)
return
1
if
self
.
options
.
threads
>
1
:
copy_fs_dirs
=
[
r
for
r
in
copy_fs_paths
if
r
[
0
]
==
self
.
DIR
]
copy_fs_paths
=
[
r
for
r
in
copy_fs_paths
if
r
[
0
]
==
self
.
FILE
]
...
...
@@ -151,7 +151,6 @@ Copy SOURCE to DESTINATION"""
#file_queue.join()
except
KeyboardInterrupt
:
print
"!"
options
.
progress
=
False
if
self
.
action_error
:
self
.
error
(
self
.
wrap_error
(
unicode
(
self
.
action_error
))
+
'
\n
'
)
...
...
@@ -229,7 +228,7 @@ Copy SOURCE to DESTINATION"""
return
bar
def
run
():
return
FS
Copy
()
.
run
()
return
FS
cp
()
.
run
()
if
__name__
==
"__main__"
:
sys
.
exit
(
run
())
fs/commands/runner.py
View file @
f1f224c1
...
...
@@ -227,13 +227,15 @@ class Command(object):
if
self
.
is_terminal
():
self
.
output
(
"
\n
"
)
return
0
except
ValueError
:
pass
except
SystemExit
:
return
0
#
except IOError:
#
return 1
#
except Exception, e:
#
self.error(self.wrap_error('Internal Error - %s\n' % unicode(e)))
#
return 1
except
IOError
:
return
1
except
Exception
,
e
:
self
.
error
(
self
.
wrap_error
(
'Internal Error -
%
s
\n
'
%
unicode
(
e
)))
return
1
...
...
fs/opener.py
View file @
f1f224c1
...
...
@@ -158,8 +158,8 @@ class ZipOpener(Opener):
@classmethod
def
get_fs
(
cls
,
registry
,
fs_name
,
fs_name_params
,
fs_path
,
writeable
,
create
):
create_zip
=
fs_name_params
==
'new'
append_zip
=
fs_name_params
==
'append'
zip_file
=
None
if
fs_path
.
startswith
(
'['
):
...
...
@@ -168,7 +168,10 @@ class ZipOpener(Opener):
raise
OpenerError
(
"Not a file"
)
container_mode
=
'r+b'
if
create_zip
:
container_mode
=
'w+'
container_mode
=
'w+b'
elif
writeable
:
container_mode
=
'w+b'
zip_file
=
container_fs
.
open
(
container_path
,
mode
=
container_mode
)
username
,
password
,
fs_path
=
registry
.
parse_credentials
(
fs_path
)
...
...
@@ -177,18 +180,21 @@ class ZipOpener(Opener):
if
zip_file
is
None
:
zip_file
=
fs_path
if
create_zip
:
if
append_zip
:
mode
=
'a'
elif
create_zip
or
create
:
mode
=
'w'
else
:
if
writeable
:
mode
=
'
a
'
mode
=
'
w
'
else
:
mode
=
'
r
'
mode
=
'
a
'
if
fs_name
==
'zip64'
:
allow_zip_64
=
True
else
:
allow_zip_64
=
False
zipfs
=
ZipFS
(
zip_file
,
mode
=
mode
,
allow_zip_64
=
allow_zip_64
)
return
zipfs
...
...
@@ -280,7 +286,7 @@ class DebugOpener(Opener):
def
get_fs
(
cls
,
registry
,
fs_name
,
fs_name_params
,
fs_path
,
writeable
,
create
):
from
fs.wrapfs.debugfs
import
DebugFS
if
fs_path
:
fs
,
path
=
registry
.
parse
(
fs_path
)
fs
,
path
=
registry
.
parse
(
fs_path
,
writeable
=
writeable
,
create
=
create
)
return
DebugFS
(
fs
,
verbose
=
False
)
if
fs_name_params
==
'ram'
:
from
fs.memoryfs
import
MemoryFS
...
...
fs/rpcfs.py
View file @
f1f224c1
...
...
@@ -24,6 +24,8 @@ def re_raise_faults(func):
try
:
return
func
(
*
args
,
**
kwds
)
except
xmlrpclib
.
Fault
,
f
:
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/zipfs.py
View file @
f1f224c1
...
...
@@ -178,7 +178,7 @@ class ZipFS(FS):
if
self
.
zip_mode
not
in
'ra'
:
raise
OperationFailedError
(
"open file"
,
path
=
path
,
msg
=
"Zip file must be opened for reading ('r') or appending ('a')"
)
msg
=
"
1
Zip file must be opened for reading ('r') or appending ('a')"
)
try
:
contents
=
self
.
zf
.
read
(
path
.
encode
(
self
.
encoding
))
except
KeyError
:
...
...
@@ -189,7 +189,7 @@ class ZipFS(FS):
if
self
.
zip_mode
not
in
'wa'
:
raise
OperationFailedError
(
"open file"
,
path
=
path
,
msg
=
"Zip file must be opened for writing ('w') or appending ('a')"
)
msg
=
"
2
Zip file must be opened for writing ('w') or appending ('a')"
)
dirname
,
filename
=
pathsplit
(
path
)
if
dirname
:
self
.
temp_fs
.
makedir
(
dirname
,
recursive
=
True
,
allow_recreate
=
True
)
...
...
@@ -211,7 +211,7 @@ class ZipFS(FS):
except
KeyError
:
raise
ResourceNotFoundError
(
path
)
except
RuntimeError
:
raise
OperationFailedError
(
"read file"
,
path
=
path
,
msg
=
"
Zip file must be op
pened with 'r' or 'a' to read"
)
raise
OperationFailedError
(
"read file"
,
path
=
path
,
msg
=
"
3 Zip file must be o
pened with 'r' or 'a' to read"
)
return
contents
@synchronize
...
...
@@ -222,7 +222,6 @@ class ZipFS(FS):
def
desc
(
self
,
path
):
return
"
%
s in zip file
%
s"
%
(
path
,
self
.
zip_path
)
def
isdir
(
self
,
path
):
return
self
.
_path_fs
.
isdir
(
path
)
...
...
@@ -236,7 +235,7 @@ class ZipFS(FS):
def
makedir
(
self
,
dirname
,
recursive
=
False
,
allow_recreate
=
False
):
dirname
=
normpath
(
dirname
)
if
self
.
zip_mode
not
in
"wa"
:
raise
OperationFailedError
(
"create directory"
,
path
=
dirname
,
msg
=
"Zip file must be opened for writing ('w') or appending ('a')"
)
raise
OperationFailedError
(
"create directory"
,
path
=
dirname
,
msg
=
"
4
Zip file must be opened for writing ('w') or appending ('a')"
)
if
not
dirname
.
endswith
(
'/'
):
dirname
+=
'/'
self
.
_add_resource
(
dirname
)
...
...
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