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
41f9600f
Commit
41f9600f
authored
Dec 22, 2010
by
willmcgugan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Windows support to fsmount command
parent
1d8a0006
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
29 deletions
+70
-29
fs/commands/fsmount.py
+63
-22
fs/expose/dokan/__init__.py
+1
-1
fs/tempfs.py
+6
-6
No files found.
fs/commands/fsmount.py
View file @
41f9600f
...
...
@@ -8,9 +8,16 @@ import os
import
os.path
import
time
platform
=
platform
.
system
()
class
FSMount
(
Command
):
usage
=
"""fsmount [FS] [SYSTEM PATH]
if
platform
==
"Windows"
:
usage
=
"""fsmount [OPTIONS]... [FS] [DRIVE LETTER]
or fsmount -u [DRIVER LETTER]
Mounts a filesystem on a drive letter"""
else
:
usage
=
"""fsmount [OPTIONS]... [FS] [SYSTEM PATH]
or fsmount -u [SYSTEM PATH]
Mounts a file system on a system path"""
...
...
@@ -30,16 +37,26 @@ Mounts a file system on a system path"""
def
do_run
(
self
,
options
,
args
):
windows
=
platform
==
"Windows"
if
options
.
unmount
:
try
:
mount_path
=
args
[
0
]
mount_path
=
args
[
0
]
[:
1
]
except
IndexError
:
self
.
error
(
'Mount path required
\n
'
)
return
1
from
fs.expose
import
fuse
fuse
.
unmount
(
mount_path
)
return
if
windows
:
from
fs.expose
import
dokan
mount_path
=
mount_path
[:
1
]
.
upper
()
dokan
.
unmount
(
mount_path
)
self
.
output
(
'unmounting
%
s:'
%
mount_path
,
True
)
return
else
:
from
fs.expose
import
fuse
fuse
.
unmount
(
mount_path
)
self
.
output
(
'unmounting
%
s'
%
mount_path
,
True
)
return
try
:
fs_url
=
args
[
0
]
except
IndexError
:
...
...
@@ -49,27 +66,51 @@ Mounts a file system on a system path"""
try
:
mount_path
=
args
[
1
]
except
IndexError
:
self
.
error
(
'Mount path required
\n
'
)
if
windows
:
mount_path
=
mount_path
[:
1
]
.
upper
()
self
.
error
(
'Drive letter required'
)
else
:
self
.
error
(
'Mount path required
\n
'
)
return
1
if
platform
.
system
()
==
'Windows'
:
pass
fs
,
path
=
self
.
open_fs
(
fs_url
,
create_dir
=
True
)
if
path
:
if
not
fs
.
isdir
(
path
):
self
.
error
(
'
%
s is not a directory on
%
s'
%
(
fs_url
.
fs
))
return
1
fs
=
fs
.
opendir
(
path
)
path
=
'/'
if
not
options
.
nocache
:
fs
.
cache_hint
(
True
)
if
windows
and
not
os
.
path
.
exists
(
mount_path
):
os
.
makedirs
(
mount_path
)
if
windows
:
from
fs.expose
import
dokan
if
len
(
mount_path
)
>
1
:
self
.
error
(
'Driver letter should be one character'
)
return
1
self
.
output
(
"Mounting
%
s on
%
s:"
%
(
fs
,
mount_path
),
True
)
flags
=
dokan
.
DOKAN_OPTION_REMOVABLE
if
options
.
debug
:
flags
|=
dokan
.
DOKAN_OPTION_DEBUG
|
dokan
.
DOKAN_OPTION_STDERR
mp
=
dokan
.
mount
(
fs
,
mount_path
,
numthreads
=
5
,
foreground
=
options
.
foreground
,
flags
=
flags
,
volname
=
str
(
fs
))
else
:
fs
,
path
=
self
.
open_fs
(
fs_url
,
create_dir
=
True
)
if
path
:
if
not
fs
.
isdir
(
path
):
self
.
error
(
'
%
s is not a directory on
%
s'
%
(
fs_url
.
fs
))
return
1
fs
=
fs
.
opendir
(
path
)
path
=
'/'
if
not
options
.
nocache
:
fs
.
cache_hint
(
True
)
if
not
os
.
path
.
exists
(
mount_path
):
os
.
makedirs
(
mount_path
)
from
fs.expose
import
fuse
self
.
output
(
"Mounting
%
s on
%
s"
%
(
fs
,
mount_path
),
True
)
if
options
.
foreground
:
fuse_process
=
fuse
.
mount
(
fs
,
mount_path
,
mount_path
,
foreground
=
True
)
else
:
if
not
os
.
fork
():
...
...
fs/expose/dokan/__init__.py
View file @
41f9600f
...
...
@@ -209,7 +209,7 @@ class FSOperations(object):
def
__init__
(
self
,
fs
,
fsname
=
"Dokan FS"
,
volname
=
"Dokan Volume"
):
if
libdokan
is
None
:
raise
OSError
(
"dokan library is not available"
)
raise
OSError
(
"dokan library
(http://dokan-dev.net/en/)
is not available"
)
self
.
fs
=
fs
self
.
fsname
=
fsname
self
.
volname
=
volname
...
...
fs/tempfs.py
View file @
41f9600f
...
...
@@ -54,12 +54,12 @@ class TempFS(OSFS):
def
__unicode__
(
self
):
return
u'<TempFS:
%
s>'
%
self
.
_temp_dir
#
def __setstate__(self, state):
#
state = super(TempFS, self).__setstate__(state)
#
self._temp_dir = tempfile.mkdtemp(self.identifier or "TempFS", dir=self.temp_dir)
#
super(TempFS, self).__init__(self._temp_dir,
#
dir_mode=self.dir_mode,
#
thread_synchronize=self.thread_synchronize)
def
__setstate__
(
self
,
state
):
state
=
super
(
TempFS
,
self
)
.
__setstate__
(
state
)
self
.
_temp_dir
=
tempfile
.
mkdtemp
(
self
.
identifier
or
"TempFS"
,
dir
=
self
.
temp_dir
)
super
(
TempFS
,
self
)
.
__init__
(
self
.
_temp_dir
,
dir_mode
=
self
.
dir_mode
,
thread_synchronize
=
self
.
thread_synchronize
)
def
close
(
self
):
"""Removes the temporary directory.
...
...
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