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
ef89627b
Commit
ef89627b
authored
Aug 15, 2012
by
gcode@loowis.durge.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Found and fixed some more sneaky Python3 str->bytes problems
parent
2f0138a2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
11 deletions
+16
-11
fs/base.py
+3
-3
fs/ftpfs.py
+1
-1
fs/memoryfs.py
+3
-2
fs/remotefs.py
+6
-4
fs/watch.py
+3
-1
No files found.
fs/base.py
View file @
ef89627b
...
@@ -39,7 +39,7 @@ from fs.local_functools import wraps
...
@@ -39,7 +39,7 @@ from fs.local_functools import wraps
import
compatibility
import
compatibility
import
six
import
six
from
six
import
PY3
from
six
import
PY3
,
b
class
DummyLock
(
object
):
class
DummyLock
(
object
):
"""A dummy lock object that doesn't do anything.
"""A dummy lock object that doesn't do anything.
...
@@ -112,13 +112,13 @@ class NullFile(object):
...
@@ -112,13 +112,13 @@ class NullFile(object):
raise
StopIteration
raise
StopIteration
def
readline
(
self
,
*
args
,
**
kwargs
):
def
readline
(
self
,
*
args
,
**
kwargs
):
return
""
return
b
(
""
)
def
close
(
self
):
def
close
(
self
):
self
.
closed
=
True
self
.
closed
=
True
def
read
(
self
,
size
=
None
):
def
read
(
self
,
size
=
None
):
return
""
return
b
(
""
)
def
seek
(
self
,
*
args
,
**
kwargs
):
def
seek
(
self
,
*
args
,
**
kwargs
):
pass
pass
...
...
fs/ftpfs.py
View file @
ef89627b
...
@@ -667,7 +667,7 @@ class _FTPFile(object):
...
@@ -667,7 +667,7 @@ class _FTPFile(object):
break
break
chunks
.
append
(
data
)
chunks
.
append
(
data
)
self
.
read_pos
+=
len
(
data
)
self
.
read_pos
+=
len
(
data
)
return
''
.
join
(
chunks
)
return
b
(
''
)
.
join
(
chunks
)
remaining_bytes
=
size
remaining_bytes
=
size
while
remaining_bytes
:
while
remaining_bytes
:
...
...
fs/memoryfs.py
View file @
ef89627b
...
@@ -21,6 +21,7 @@ from os import SEEK_END
...
@@ -21,6 +21,7 @@ from os import SEEK_END
import
threading
import
threading
import
six
import
six
from
six
import
b
def
_check_mode
(
mode
,
mode_chars
):
def
_check_mode
(
mode
,
mode_chars
):
...
@@ -574,7 +575,7 @@ class MemoryFS(FS):
...
@@ -574,7 +575,7 @@ class MemoryFS(FS):
if
dir_entry
.
isdir
():
if
dir_entry
.
isdir
():
info
[
'st_mode'
]
=
0755
|
stat
.
S_IFDIR
info
[
'st_mode'
]
=
0755
|
stat
.
S_IFDIR
else
:
else
:
info
[
'size'
]
=
len
(
dir_entry
.
data
or
''
)
info
[
'size'
]
=
len
(
dir_entry
.
data
or
b
(
''
)
)
info
[
'st_mode'
]
=
0666
|
stat
.
S_IFREG
info
[
'st_mode'
]
=
0666
|
stat
.
S_IFREG
return
info
return
info
...
@@ -630,7 +631,7 @@ class MemoryFS(FS):
...
@@ -630,7 +631,7 @@ class MemoryFS(FS):
raise
ResourceNotFoundError
(
path
)
raise
ResourceNotFoundError
(
path
)
if
not
dir_entry
.
isfile
():
if
not
dir_entry
.
isfile
():
raise
ResourceInvalidError
(
path
,
msg
=
"not a file:
%(path)
s"
)
raise
ResourceInvalidError
(
path
,
msg
=
"not a file:
%(path)
s"
)
return
dir_entry
.
data
or
''
return
dir_entry
.
data
or
b
(
''
)
@synchronize
@synchronize
def
setcontents
(
self
,
path
,
data
,
chunk_size
=
1024
*
64
):
def
setcontents
(
self
,
path
,
data
,
chunk_size
=
1024
*
64
):
...
...
fs/remotefs.py
View file @
ef89627b
...
@@ -10,6 +10,9 @@ from json import dumps
...
@@ -10,6 +10,9 @@ from json import dumps
import
Queue
as
queue
import
Queue
as
queue
import
socket
import
socket
from
six
import
b
class
PacketHandler
(
threading
.
Thread
):
class
PacketHandler
(
threading
.
Thread
):
def
__init__
(
self
,
transport
,
prelude_callback
=
None
):
def
__init__
(
self
,
transport
,
prelude_callback
=
None
):
...
@@ -99,7 +102,7 @@ class _SocketFile(object):
...
@@ -99,7 +102,7 @@ class _SocketFile(object):
try
:
try
:
return
self
.
socket
.
recv
(
size
)
return
self
.
socket
.
recv
(
size
)
except
:
except
:
return
''
return
b
(
''
)
def
write
(
self
,
data
):
def
write
(
self
,
data
):
self
.
socket
.
sendall
(
data
)
self
.
socket
.
sendall
(
data
)
...
@@ -145,7 +148,7 @@ class RemoteFS(FS):
...
@@ -145,7 +148,7 @@ class RemoteFS(FS):
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
sock
.
connect
((
self
.
addr
,
self
.
port
))
sock
.
connect
((
self
.
addr
,
self
.
port
))
socket_file
=
_SocketFile
(
sock
)
socket_file
=
_SocketFile
(
sock
)
socket_file
.
write
(
'pyfs/0.1
\n
'
)
socket_file
.
write
(
b
(
'pyfs/0.1
\n
'
)
)
return
socket_file
return
socket_file
def
_make_call
(
self
,
method_name
,
*
args
,
**
kwargs
):
def
_make_call
(
self
,
method_name
,
*
args
,
**
kwargs
):
...
@@ -185,4 +188,4 @@ if __name__ == "__main__":
...
@@ -185,4 +188,4 @@ if __name__ == "__main__":
rfs
=
RemoteFS
()
rfs
=
RemoteFS
()
rfs
.
close
()
rfs
.
close
()
\ No newline at end of file
fs/watch.py
View file @
ef89627b
...
@@ -41,6 +41,8 @@ from fs.wrapfs import WrapFS
...
@@ -41,6 +41,8 @@ from fs.wrapfs import WrapFS
from
fs.base
import
FS
from
fs.base
import
FS
from
fs.filelike
import
FileWrapper
from
fs.filelike
import
FileWrapper
from
six
import
b
class
EVENT
(
object
):
class
EVENT
(
object
):
"""Base class for change notification events."""
"""Base class for change notification events."""
...
@@ -304,7 +306,7 @@ class WatchableFS(WatchableFSMixin,WrapFS):
...
@@ -304,7 +306,7 @@ class WatchableFS(WatchableFSMixin,WrapFS):
self
.
notify_watchers
(
ACCESSED
,
path
)
self
.
notify_watchers
(
ACCESSED
,
path
)
return
WatchedFile
(
f
,
self
,
path
,
mode
)
return
WatchedFile
(
f
,
self
,
path
,
mode
)
def
setcontents
(
self
,
path
,
data
=
''
,
chunk_size
=
64
*
1024
):
def
setcontents
(
self
,
path
,
data
=
b
(
''
)
,
chunk_size
=
64
*
1024
):
existed
=
self
.
wrapped_fs
.
isfile
(
path
)
existed
=
self
.
wrapped_fs
.
isfile
(
path
)
ret
=
super
(
WatchableFS
,
self
)
.
setcontents
(
path
,
data
,
chunk_size
=
chunk_size
)
ret
=
super
(
WatchableFS
,
self
)
.
setcontents
(
path
,
data
,
chunk_size
=
chunk_size
)
if
not
existed
:
if
not
existed
:
...
...
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