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
f5c7b0f0
Commit
f5c7b0f0
authored
Dec 06, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Opener fixes
parent
8ff1c9b1
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
56 additions
and
11 deletions
+56
-11
fs/commands/fscat.py
+5
-0
fs/commands/fscp.py
+3
-0
fs/commands/fsinfo.py
+3
-0
fs/commands/fsls.py
+4
-0
fs/commands/fsmv.py
+4
-0
fs/commands/fsrm.py
+3
-0
fs/commands/fsserve.py
+5
-2
fs/commands/fstree.py
+3
-0
fs/commands/runner.py
+6
-5
fs/expose/http.py
+2
-2
fs/opener.py
+16
-1
fs/zipfs.py
+2
-1
No files found.
fs/commands/fscat.py
View file @
f5c7b0f0
...
@@ -6,6 +6,11 @@ import sys
...
@@ -6,6 +6,11 @@ import sys
class
FSCat
(
Command
):
class
FSCat
(
Command
):
usage
=
"""fscat [OPTION]... [FILE]...
Concetanate FILE(s)"""
version
=
"1.0"
def
do_run
(
self
,
options
,
args
):
def
do_run
(
self
,
options
,
args
):
count
=
0
count
=
0
for
fs
,
path
,
is_dir
in
self
.
get_resources
(
args
):
for
fs
,
path
,
is_dir
in
self
.
get_resources
(
args
):
...
...
fs/commands/fscp.py
View file @
f5c7b0f0
...
@@ -47,6 +47,9 @@ class FSCopy(Command):
...
@@ -47,6 +47,9 @@ class FSCopy(Command):
DIR
,
FILE
=
0
,
1
DIR
,
FILE
=
0
,
1
usage
=
"""fscp [OPTION]... [SOURCE]... [DESTINATION]
Copy SOURCE to DESTINATION"""
def
get_action
(
self
):
def
get_action
(
self
):
return
copyfile
return
copyfile
...
...
fs/commands/fsinfo.py
View file @
f5c7b0f0
...
@@ -8,6 +8,9 @@ from datetime import datetime
...
@@ -8,6 +8,9 @@ from datetime import datetime
class
FSInfo
(
Command
):
class
FSInfo
(
Command
):
usage
=
"""fsinfo [OPTION]... [PATH]
Display information regarding an FS resource"""
def
get_optparse
(
self
):
def
get_optparse
(
self
):
optparse
=
super
(
FSInfo
,
self
)
.
get_optparse
()
optparse
=
super
(
FSInfo
,
self
)
.
get_optparse
()
optparse
.
add_option
(
'-k'
,
'--key'
,
dest
=
'keys'
,
action
=
'append'
,
default
=
[],
optparse
.
add_option
(
'-k'
,
'--key'
,
dest
=
'keys'
,
action
=
'append'
,
default
=
[],
...
...
fs/commands/fsls.py
View file @
f5c7b0f0
...
@@ -8,6 +8,10 @@ import sys
...
@@ -8,6 +8,10 @@ import sys
class
FSList
(
Command
):
class
FSList
(
Command
):
usage
=
"""fsls [OPTIONS]... [PATH]
List contents of [PATH]"""
def
get_optparse
(
self
):
def
get_optparse
(
self
):
optparse
=
super
(
FSList
,
self
)
.
get_optparse
()
optparse
=
super
(
FSList
,
self
)
.
get_optparse
()
optparse
.
add_option
(
'-u'
,
'--full'
,
dest
=
'fullpath'
,
action
=
"store_true"
,
default
=
False
,
optparse
.
add_option
(
'-u'
,
'--full'
,
dest
=
'fullpath'
,
action
=
"store_true"
,
default
=
False
,
...
...
fs/commands/fsmv.py
View file @
f5c7b0f0
...
@@ -3,6 +3,10 @@ from fs.commands import fscp
...
@@ -3,6 +3,10 @@ from fs.commands import fscp
import
sys
import
sys
class
FSMove
(
fscp
.
FSCopy
):
class
FSMove
(
fscp
.
FSCopy
):
usage
=
"""fsmv [OPTION]... [SOURCE] [DESTINATION]
Move files from SOURCE to DESTINATION"""
def
get_action
(
self
):
def
get_action
(
self
):
return
movefile
return
movefile
...
...
fs/commands/fsrm.py
View file @
f5c7b0f0
...
@@ -7,6 +7,9 @@ import sys
...
@@ -7,6 +7,9 @@ import sys
class
FSrm
(
Command
):
class
FSrm
(
Command
):
usage
=
"""fsrm [OPTION]... [PATH]
Remove a file or directory at PATH"""
def
get_optparse
(
self
):
def
get_optparse
(
self
):
optparse
=
super
(
FSrm
,
self
)
.
get_optparse
()
optparse
=
super
(
FSrm
,
self
)
.
get_optparse
()
optparse
.
add_option
(
'-f'
,
'--force'
,
dest
=
'force'
,
action
=
'store_true'
,
default
=
False
,
optparse
.
add_option
(
'-f'
,
'--force'
,
dest
=
'force'
,
action
=
'store_true'
,
default
=
False
,
...
...
fs/commands/fsserve.py
View file @
f5c7b0f0
...
@@ -8,6 +8,9 @@ from fs.utils import print_fs
...
@@ -8,6 +8,9 @@ from fs.utils import print_fs
class
FSServe
(
Command
):
class
FSServe
(
Command
):
"""fsserve [OPTION]... [PATH]
Serves the contents of PATH with one of a number of methods"""
def
get_optparse
(
self
):
def
get_optparse
(
self
):
optparse
=
super
(
FSServe
,
self
)
.
get_optparse
()
optparse
=
super
(
FSServe
,
self
)
.
get_optparse
()
optparse
.
add_option
(
'-t'
,
'--type'
,
dest
=
'type'
,
type
=
"string"
,
default
=
"http"
,
optparse
.
add_option
(
'-t'
,
'--type'
,
dest
=
'type'
,
type
=
"string"
,
default
=
"http"
,
...
@@ -23,7 +26,7 @@ class FSServe(Command):
...
@@ -23,7 +26,7 @@ class FSServe(Command):
try
:
try
:
fs_url
=
args
[
0
]
fs_url
=
args
[
0
]
except
IndexError
:
except
IndexError
:
self
.
error
(
'FS required
\n
'
)
self
.
error
(
'FS
path
required
\n
'
)
return
1
return
1
fs
,
path
=
self
.
open_fs
(
fs_url
)
fs
,
path
=
self
.
open_fs
(
fs_url
)
...
@@ -42,7 +45,7 @@ class FSServe(Command):
...
@@ -42,7 +45,7 @@ class FSServe(Command):
from
fs.expose.xmlrpc
import
RPCFSServer
from
fs.expose.xmlrpc
import
RPCFSServer
if
port
is
None
:
if
port
is
None
:
port
=
80
port
=
80
s
=
RPCFSServer
(
fs
,
(
options
.
addr
,
options
.
port
))
s
=
RPCFSServer
(
fs
,
(
options
.
addr
,
port
))
s
.
serve_forever
()
s
.
serve_forever
()
elif
options
.
type
==
'sftp'
:
elif
options
.
type
==
'sftp'
:
...
...
fs/commands/fstree.py
View file @
f5c7b0f0
...
@@ -8,6 +8,9 @@ from fs.utils import print_fs
...
@@ -8,6 +8,9 @@ from fs.utils import print_fs
class
FSTree
(
Command
):
class
FSTree
(
Command
):
usage
=
"""fstree [OPTION]... [PATH]
Recursively display the contents of PATH in an ascii tree"""
def
get_optparse
(
self
):
def
get_optparse
(
self
):
optparse
=
super
(
FSTree
,
self
)
.
get_optparse
()
optparse
=
super
(
FSTree
,
self
)
.
get_optparse
()
optparse
.
add_option
(
'-d'
,
'--depth'
,
dest
=
'depth'
,
type
=
"int"
,
default
=
5
,
optparse
.
add_option
(
'-d'
,
'--depth'
,
dest
=
'depth'
,
type
=
"int"
,
default
=
5
,
...
...
fs/commands/runner.py
View file @
f5c7b0f0
...
@@ -42,9 +42,10 @@ def _unicode(text):
...
@@ -42,9 +42,10 @@ def _unicode(text):
class
Command
(
object
):
class
Command
(
object
):
usage
=
''
version
=
''
def
__init__
(
self
,
usage
=
''
,
version
=
''
):
def
__init__
(
self
,
usage
=
''
,
version
=
''
):
self
.
usage
=
usage
self
.
version
=
version
self
.
output_file
=
sys
.
stdout
self
.
output_file
=
sys
.
stdout
self
.
error_file
=
sys
.
stderr
self
.
error_file
=
sys
.
stderr
self
.
encoding
=
getattr
(
self
.
output_file
,
'encoding'
,
'utf-8'
)
or
'utf-8'
self
.
encoding
=
getattr
(
self
.
output_file
,
'encoding'
,
'utf-8'
)
or
'utf-8'
...
@@ -230,9 +231,9 @@ class Command(object):
...
@@ -230,9 +231,9 @@ class Command(object):
return
0
return
0
#except IOError:
#except IOError:
# return 1
# return 1
except
Exception
,
e
:
#
except Exception, e:
self
.
error
(
self
.
wrap_error
(
'Internal Error -
%
s
\n
'
%
unicode
(
e
)))
#
self.error(self.wrap_error('Internal Error - %s\n' % unicode(e)))
return
1
#
return 1
...
...
fs/expose/http.py
View file @
f5c7b0f0
...
@@ -65,8 +65,8 @@ class FSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
...
@@ -65,8 +65,8 @@ class FSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
try
:
try
:
info
=
self
.
_fs
.
getinfo
(
path
)
info
=
self
.
_fs
.
getinfo
(
path
)
f
=
self
.
_fs
.
open
(
path
,
'r'
)
f
=
self
.
_fs
.
open
(
path
,
'r'
)
except
FSError
:
except
FSError
,
e
:
self
.
send_error
(
404
,
"File not found"
)
self
.
send_error
(
404
,
str
(
e
)
)
return
None
return
None
self
.
send_response
(
200
)
self
.
send_response
(
200
)
self
.
send_header
(
"Content-type"
,
ctype
)
self
.
send_header
(
"Content-type"
,
ctype
)
...
...
fs/opener.py
View file @
f5c7b0f0
...
@@ -76,13 +76,15 @@ class OpenerRegistry(object):
...
@@ -76,13 +76,15 @@ class OpenerRegistry(object):
fs_name
,
paren_url
,
fs_url
,
path
=
self
.
split_segments
(
fs_url
)
fs_name
,
paren_url
,
fs_url
,
path
=
self
.
split_segments
(
fs_url
)
fs_url
=
fs_url
or
paren_url
if
fs_name
is
None
and
path
is
None
:
if
fs_name
is
None
and
path
is
None
:
fs_url
=
os
.
path
.
expanduser
(
os
.
path
.
expandvars
(
fs_url
))
fs_url
=
os
.
path
.
normpath
(
os
.
path
.
abspath
(
fs_url
))
fs_url
,
path
=
pathsplit
(
fs_url
)
fs_url
,
path
=
pathsplit
(
fs_url
)
if
not
fs_url
:
if
not
fs_url
:
fs_url
=
'/'
fs_url
=
'/'
fs_name
=
fs_name
or
self
.
default_opener
fs_name
=
fs_name
or
self
.
default_opener
fs_url
=
fs_url
or
paren_url
if
fs_name
is
None
:
if
fs_name
is
None
:
fs_name
=
fs_default_name
fs_name
=
fs_default_name
...
@@ -190,6 +192,17 @@ class ZipOpener(Opener):
...
@@ -190,6 +192,17 @@ class ZipOpener(Opener):
zipfs
=
ZipFS
(
zip_file
,
mode
=
mode
,
allow_zip_64
=
allow_zip_64
)
zipfs
=
ZipFS
(
zip_file
,
mode
=
mode
,
allow_zip_64
=
allow_zip_64
)
return
zipfs
return
zipfs
class
RPCOpener
(
Opener
):
names
=
[
'rpc'
]
@classmethod
def
get_fs
(
cls
,
registry
,
fs_name
,
fs_name_params
,
fs_path
,
writeable
,
create
):
from
fs.rpcfs
import
RPCFS
username
,
password
,
fs_path
=
registry
.
parse_credentials
(
fs_path
)
if
not
fs_path
.
startswith
(
'http://'
):
fs_path
=
'http://'
+
fs_path
rpcfs
=
RPCFS
(
fs_path
)
return
rpcfs
class
FTPOpener
(
Opener
):
class
FTPOpener
(
Opener
):
names
=
[
'ftp'
]
names
=
[
'ftp'
]
...
@@ -287,6 +300,7 @@ class TempOpener(Opener):
...
@@ -287,6 +300,7 @@ class TempOpener(Opener):
opener
=
OpenerRegistry
([
OSFSOpener
,
opener
=
OpenerRegistry
([
OSFSOpener
,
ZipOpener
,
ZipOpener
,
RPCOpener
,
FTPOpener
,
FTPOpener
,
SFTPOpener
,
SFTPOpener
,
MemOpener
,
MemOpener
,
...
@@ -297,6 +311,7 @@ opener = OpenerRegistry([OSFSOpener,
...
@@ -297,6 +311,7 @@ opener = OpenerRegistry([OSFSOpener,
def
main
():
def
main
():
fs
,
path
=
opener
.
parse
(
'galleries.zip'
)
print
fs
,
path
print
fs
,
path
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
...
...
fs/zipfs.py
View file @
f5c7b0f0
...
@@ -261,5 +261,6 @@ class ZipFS(FS):
...
@@ -261,5 +261,6 @@ class ZipFS(FS):
if
'date_time'
in
zinfo
:
if
'date_time'
in
zinfo
:
info
[
'created_time'
]
=
datetime
.
datetime
(
*
zinfo
[
'date_time'
])
info
[
'created_time'
]
=
datetime
.
datetime
(
*
zinfo
[
'date_time'
])
info
.
update
(
zinfo
)
info
.
update
(
zinfo
)
if
'FileHeader'
in
info
:
del
info
[
'FileHeader'
]
return
info
return
info
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