durusmail: durus-users: Durus 3.7 and Windows
Durus 3.7 and Windows
2007-08-08
2007-08-08
2007-08-08
2007-08-13
2007-08-14
2007-08-14
2007-08-14
2007-08-14
2007-08-15
2007-08-15
2007-08-15
2007-08-15
2007-08-15
Durus 3.7 and Windows
Matthew Scott
2007-08-14
On 8/14/07, Matthew Scott  wrote:
> I think this is enough information for me to make a patch now.  Cross
> your fingers :)


Not quite.  Here is the patch I tried:


Index: file.py
===================================================================
--- file.py     (revision 3461)
+++ file.py     (working copy)
@@ -47,11 +47,19 @@
     def seek_end(self):
         self.file.seek(0, 2)

-    def read(self, n=None):
-        if n is None:
-            return self.file.read()
-        else:
-            return self.file.read(n)
+    if os.name == 'nt':
+        def read(self, n=None):
+            self.file.flush()
+            if n is None:
+                return self.file.read()
+            else:
+                return self.file.read(n)
+    else:
+        def read(self, n=None):
+            if n is None:
+                return self.file.read()
+            else:
+                return self.file.read(n)

     def tell(self):
         return self.file.tell()


More oddity ensues.  When I run the unit tests for SchevoDurus, it
works up to a point for shelf storage, then I get random exceptions,
including:

ShortRead: {'position': 4503599636254754L, 'transaction_start': 40L,
'transaction_end': 9314965144923910813L}
ShortRead: {'position': 7235423626387813778L, 'transaction_start':
40L, 'transaction_end': 9628575606031655734L}
ShortRead: {'position': 3270750659515333737L, 'transaction_start':
40L, 'transaction_end': 17523070416054170261L}

I also got an OverflowError at some point but it scrolled away and I
don't have the patience to reproduce it.

Additionally, the patch breaks FileStorage.  I amended my "t.py"
script as follows:

from os import unlink, path
if path.exists('foo.durus'):
    unlink('foo.durus')
if path.exists('foo2.durus'):
    unlink('foo2.durus')
from durus.file_storage import ShelfStorage
s = ShelfStorage('foo.durus')
s.close()
print 'shelf storage opened and closed.'
from durus.file_storage import FileStorage
f = FileStorage('foo2.durus')
f.close()
print 'file storage opened and closed.'

Now, when I run it, I get this output:

shelf storage opened and closed.
Traceback (most recent call last):
  File "t.py", line 11, in ?
    f = FileStorage('foo2.durus')
  File "c:\env\schevo24\lib\python2.4\durus-3.7_schevo1-py2.4-win32.egg\durus\fi
le_storage.py",
line 262, in __init__
    self._build_index(repair)
  File "c:\env\schevo24\lib\python2.4\durus-3.7_schevo1-py2.4-win32.egg\durus\fi
le_storage.py",
line 421, in _build_index
    index_offset = read_int8(self.fp)
  File "c:\env\schevo24\lib\python2.4\durus-3.7_schevo1-py2.4-win32.egg\durus\ut
ils.py",
line 63, in read_int8
    return str_to_int8(read(f, 8))
  File "c:\env\schevo24\lib\python2.4\durus-3.7_schevo1-py2.4-win32.egg\durus\ut
ils.py",
line 38, in read
    raise ShortRead()
durus.utils.ShortRead



Ack!


Anyways, time to prepare dinner.  Will continue the quest later on...


--
Matthew R. Scott
reply