From 7b91075229953c8c9fa26b7a899265e9680e38d7 Mon Sep 17 00:00:00 2001 From: "Dr. Peter Poeml" Date: Sun, 16 Mar 2008 19:02:38 +0000 Subject: [PATCH] handle mmap failure on filesystems like NTFS, which may not support memory mapping when mounted under Linux --- osc/core.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/osc/core.py b/osc/core.py index 81d9c4dc..b037b951 100755 --- a/osc/core.py +++ b/osc/core.py @@ -1273,7 +1273,15 @@ def http_request(method, url, data=None, file=None): else: import mmap filefd = open(file, 'r+') - data = mmap.mmap(filefd.fileno(), os.path.getsize(file)) + try: + data = mmap.mmap(filefd.fileno(), os.path.getsize(file)) + except EnvironmentError, e: + if e.errno == 19: + sys.exit('\n\n%s\nThe file \'%s\' could not be memory mapped. It is ' \ + '\non a filesystem which does not support this.' % (e, file)) + else: + raise + fd = urllib2.urlopen(req, data=data)