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
155f51dc
Commit
155f51dc
authored
Dec 11, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added fsmkdir command
parent
99ddb4ec
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
49 additions
and
19 deletions
+49
-19
fs/commands/fsmkdir
+4
-0
fs/commands/fsmkdir.py
+25
-0
fs/commands/fsserve.py
+10
-4
fs/commands/runner.py
+0
-2
fs/expose/http.py
+0
-3
fs/opener.py
+8
-9
setup.py
+2
-1
No files found.
fs/commands/fsmkdir
0 → 100644
View file @
155f51dc
#!/usr/bin/env python
import
sys
from
fs.commands.fsmkdir
import
run
sys
.
exit
(
run
())
fs/commands/fsmkdir.py
0 → 100644
View file @
155f51dc
#!/usr/bin/env python
from
fs.opener
import
opener
from
fs.commands.runner
import
Command
import
sys
class
FSMkdir
(
Command
):
usage
=
"""fsmkdir [PATH]
Make a directory"""
version
=
"1.0"
def
do_run
(
self
,
options
,
args
):
for
fs_url
in
args
:
fs
,
path
=
self
.
open_fs
(
fs_url
,
create
=
True
)
def
run
():
return
FSMkdir
()
.
run
()
if
__name__
==
"__main__"
:
sys
.
exit
(
run
())
\ No newline at end of file
fs/commands/fsserve.py
View file @
155f51dc
...
...
@@ -26,15 +26,14 @@ Serves the contents of PATH with one of a number of methods"""
try
:
fs_url
=
args
[
0
]
except
IndexError
:
self
.
error
(
'FS path required
\n
'
)
return
1
fs_url
=
'./'
fs
,
path
=
self
.
open_fs
(
fs_url
)
if
path
and
fs
.
isdir
(
path
):
fs
,
path
=
fs
.
opendir
(
path
),
'/'
port
=
options
.
port
try
:
if
options
.
type
==
'http'
:
from
fs.expose.http
import
serve_fs
if
port
is
None
:
...
...
@@ -63,6 +62,13 @@ Serves the contents of PATH with one of a number of methods"""
else
:
self
.
error
(
"Server type '
%
s' not recognised
\n
"
%
options
.
type
)
except
IOError
,
e
:
if
e
.
errno
==
13
:
self
.
error
(
'Permission denied
\n
'
)
return
1
else
:
self
.
error
(
e
.
strerror
+
'
\n
'
)
return
1
def
run
():
return
FSServe
()
.
run
()
...
...
fs/commands/runner.py
View file @
155f51dc
...
...
@@ -226,8 +226,6 @@ class Command(object):
# 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
...
...
fs/expose/http.py
View file @
155f51dc
...
...
@@ -131,7 +131,6 @@ def serve_fs(fs, address='', port=8000):
#class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
# pass
httpd
=
SocketServer
.
TCPServer
((
address
,
port
),
Handler
,
bind_and_activate
=
False
)
#httpd = ThreadedTCPServer((address, port), Handler, bind_and_activate=False)
httpd
.
allow_reuse_address
=
True
...
...
@@ -139,9 +138,7 @@ def serve_fs(fs, address='', port=8000):
httpd
.
server_activate
()
server_thread
=
threading
.
Thread
(
target
=
httpd
.
serve_forever
)
server_thread
.
setDaemon
(
True
)
server_thread
.
start
()
try
:
while
True
:
time
.
sleep
(
0.1
)
...
...
fs/opener.py
View file @
155f51dc
...
...
@@ -133,7 +133,6 @@ class OpenerRegistry(object):
return
fs
,
fs_path
def
parse_credentials
(
self
,
url
):
username
=
None
...
...
@@ -154,7 +153,7 @@ class OpenerRegistry(object):
return
fs_name
,
None
def
open
(
self
,
fs_url
,
mode
=
'r'
):
writeable
=
'w'
in
mode
or
'a'
in
mode
writeable
=
'w'
in
mode
or
'a'
in
mode
or
'+'
in
mode
fs
,
path
=
self
.
parse
(
fs_url
,
writeable
=
writeable
)
file_object
=
fs
.
open
(
path
,
mode
)
return
file_object
...
...
@@ -179,12 +178,11 @@ class OSFSOpener(Opener):
@classmethod
def
get_fs
(
cls
,
registry
,
fs_name
,
fs_name_params
,
fs_path
,
writeable
,
create
):
from
fs.osfs
import
OSFS
username
,
password
,
fs_path
=
registry
.
parse_credentials
(
fs_path
)
path
=
_expand_syspath
(
fs_path
)
if
create
:
sys
.
makedirs
(
fs_path
)
from
fs.osfs
import
_os_makedirs
_os_makedirs
(
fs_path
)
if
os
.
path
.
isdir
(
path
):
osfs
=
OSFS
(
path
)
filepath
=
None
...
...
@@ -236,6 +234,7 @@ class ZipOpener(Opener):
zipfs
=
ZipFS
(
zip_file
,
mode
=
mode
,
allow_zip_64
=
allow_zip_64
)
return
zipfs
,
None
class
RPCOpener
(
Opener
):
names
=
[
'rpc'
]
...
...
@@ -255,6 +254,7 @@ class RPCOpener(Opener):
return
rpcfs
,
path
or
None
class
FTPOpener
(
Opener
):
names
=
[
'ftp'
]
...
...
@@ -320,9 +320,6 @@ class SFTPOpener(Opener):
else
:
host
=
(
addr
,
port
)
#if not username or not password:
# raise OpenerError('SFTP requires authentication')
if
create
:
sftpfs
=
SFTPFS
(
host
,
root_path
=
'/'
,
**
credentials
)
if
not
sftpfs
.
_transport
.
is_authenticated
():
...
...
@@ -350,6 +347,7 @@ class MemOpener(Opener):
memfs
=
memfs
.
makeopendir
(
fs_path
)
return
memfs
,
None
class
DebugOpener
(
Opener
):
names
=
[
'debug'
]
...
...
@@ -366,13 +364,14 @@ class DebugOpener(Opener):
from
fs.tempfs
import
TempFS
return
DebugFS
(
TempFS
(),
identifier
=
fs_name_params
,
verbose
=
False
),
None
class
TempOpener
(
Opener
):
names
=
[
'temp'
]
@classmethod
def
get_fs
(
cls
,
registry
,
fs_name
,
fs_name_params
,
fs_path
,
writeable
,
create
):
from
fs.tempfs
import
TempFS
return
TempFS
(
identifier
=
fs_name_params
,
temp_dir
=
fs_path
),
None
return
TempFS
(
identifier
=
fs_name_params
,
temp_dir
=
fs_path
,
create
=
create
),
None
opener
=
OpenerRegistry
([
OSFSOpener
,
...
...
setup.py
View file @
155f51dc
...
...
@@ -11,7 +11,8 @@ COMMANDS = ['fscat',
'fscp'
,
'fsrm'
,
'fsserve'
,
'fstree'
]
'fstree'
,
'fsmkdir'
]
classifiers
=
[
...
...
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