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
71d3b857
Commit
71d3b857
authored
Oct 15, 2010
by
rfkelly0
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide working alternative if SpooledTemporaryFile is not available.
parent
4e173179
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
5 deletions
+12
-5
fs/remote.py
+12
-5
No files found.
fs/remote.py
View file @
71d3b857
...
@@ -36,11 +36,15 @@ from fs import SEEK_SET, SEEK_CUR, SEEK_END
...
@@ -36,11 +36,15 @@ from fs import SEEK_SET, SEEK_CUR, SEEK_END
try
:
try
:
from
tempfile
import
SpooledTemporaryFile
from
tempfile
import
SpooledTemporaryFile
def
_MakeSpooledTempFile
(
*
args
,
**
kwds
):
return
SpooledTemporaryFile
(
*
args
,
**
kwds
)
except
ImportError
:
except
ImportError
:
from
tempfile
import
NamedTemporaryFile
from
tempfile
import
NamedTemporaryFile
class
SpooledTemporaryFile
(
NamedTemporaryFile
):
class
SpooledTemporaryFile
(
object
):
def
__init__
(
self
,
max_size
=
0
,
*
args
,
**
kwds
):
"""Fake SpooledTemporaryFile, for faking out isinstance() checks."""
NamedTemporaryFile
.
__init__
(
self
,
*
args
,
**
kwds
)
pass
def
_MakeSpooledTempFile
(
max_size
=
0
,
*
args
,
**
kwds
):
return
NamedTemporaryFile
(
*
args
,
**
kwds
)
class
RemoteFileBuffer
(
object
):
class
RemoteFileBuffer
(
object
):
...
@@ -77,7 +81,7 @@ class RemoteFileBuffer(object):
...
@@ -77,7 +81,7 @@ class RemoteFileBuffer(object):
optional argument 'rfile' is provided, it must be a read()-able
optional argument 'rfile' is provided, it must be a read()-able
object or a string containing the initial file contents.
object or a string containing the initial file contents.
"""
"""
self
.
file
=
SpooledTemporary
File
(
max_size
=
self
.
max_size_in_memory
)
self
.
file
=
_MakeSpooledTemp
File
(
max_size
=
self
.
max_size_in_memory
)
self
.
fs
=
fs
self
.
fs
=
fs
self
.
path
=
path
self
.
path
=
path
self
.
mode
=
mode
self
.
mode
=
mode
...
@@ -273,7 +277,10 @@ class RemoteFileBuffer(object):
...
@@ -273,7 +277,10 @@ class RemoteFileBuffer(object):
else
:
else
:
self
.
file
.
_file
.
truncate
(
size
)
self
.
file
.
_file
.
truncate
(
size
)
else
:
else
:
self
.
file
.
truncate
(
size
)
if
size
is
None
:
self
.
file
.
truncate
()
else
:
self
.
file
.
truncate
(
size
)
self
.
_changed
=
True
self
.
_changed
=
True
if
not
self
.
_eof
and
self
.
_readlen
<
size
:
if
not
self
.
_eof
and
self
.
_readlen
<
size
:
...
...
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