mirror of
https://github.com/openSUSE/osc.git
synced 2025-02-27 20:52:14 +01:00
mmap.mmap works differently under windows
This commit is contained in:
parent
8f38f169d5
commit
0fa507a782
@ -1536,8 +1536,10 @@ def http_request(method, url, headers={}, data=None, file=None, timeout=100):
|
|||||||
import mmap
|
import mmap
|
||||||
filefd = open(file, 'r')
|
filefd = open(file, 'r')
|
||||||
try:
|
try:
|
||||||
data = mmap.mmap(filefd.fileno(), os.path.getsize(file),
|
if sys.platform[:3] != 'win':
|
||||||
mmap.MAP_SHARED, mmap.PROT_READ)
|
data = mmap.mmap(filefd.fileno(), os.path.getsize(file), mmap.MAP_SHARED, mmap.PROT_READ)
|
||||||
|
else:
|
||||||
|
data = mmap.mmap(filefd.fileno(), os.path.getsize(file))
|
||||||
data = buffer(data)
|
data = buffer(data)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError, e:
|
||||||
if e.errno == 19:
|
if e.errno == 19:
|
||||||
|
@ -147,7 +147,10 @@ class Ar:
|
|||||||
import mmap
|
import mmap
|
||||||
self.__file = open(self.filename, 'rb')
|
self.__file = open(self.filename, 'rb')
|
||||||
try:
|
try:
|
||||||
self.__file = mmap.mmap(self.__file.fileno(), 0, prot=mmap.PROT_READ)
|
if sys.platform[:3] != 'win':
|
||||||
|
self.__file = mmap.mmap(self.__file.fileno(), 0, prot=mmap.PROT_READ)
|
||||||
|
else:
|
||||||
|
self.__file = mmap.mmap(self.__file.fileno(), 0)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError, e:
|
||||||
if e.errno == 19:
|
if e.errno == 19:
|
||||||
print >>sys.stderr, 'cannot use mmap to read the file, falling back to the default io'
|
print >>sys.stderr, 'cannot use mmap to read the file, falling back to the default io'
|
||||||
|
@ -17,6 +17,7 @@ import mmap
|
|||||||
import os
|
import os
|
||||||
import stat
|
import stat
|
||||||
import struct
|
import struct
|
||||||
|
import sys
|
||||||
|
|
||||||
# format implementation is based on src/copyin.c and src/util.c (see cpio sources)
|
# format implementation is based on src/copyin.c and src/util.c (see cpio sources)
|
||||||
|
|
||||||
@ -139,7 +140,10 @@ class Cpio:
|
|||||||
if not self.__file:
|
if not self.__file:
|
||||||
self.__file = open(self.filename, 'rb')
|
self.__file = open(self.filename, 'rb')
|
||||||
try:
|
try:
|
||||||
self.__file = mmap.mmap(self.__file.fileno(), 0, prot = mmap.PROT_READ)
|
if sys.platform[:3] != 'win':
|
||||||
|
self.__file = mmap.mmap(self.__file.fileno(), 0, prot = mmap.PROT_READ)
|
||||||
|
else:
|
||||||
|
self.__file = mmap.mmap(self.__file.fileno(), 0)
|
||||||
except EnvironmentError, e:
|
except EnvironmentError, e:
|
||||||
if e.errno == 19:
|
if e.errno == 19:
|
||||||
print >>sys.stderr, 'cannot use mmap to read the file, failing back to default'
|
print >>sys.stderr, 'cannot use mmap to read the file, failing back to default'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user