Various fixes to support Python 2.5

This commit is contained in:
Jonas Borgström 2011-06-23 22:47:51 +02:00
parent 9e11ae567d
commit fae9433c11
6 changed files with 10 additions and 4 deletions

View File

@ -1,3 +1,4 @@
from __future__ import with_statement
from datetime import datetime
from getpass import getuser
import msgpack

View File

@ -1,3 +1,4 @@
from __future__ import with_statement
from ConfigParser import RawConfigParser
import fcntl
import msgpack

View File

@ -1,3 +1,4 @@
from __future__ import with_statement
import argparse
from datetime import datetime, timedelta
from fnmatch import fnmatchcase

View File

@ -1,3 +1,4 @@
from __future__ import with_statement
from getpass import getpass
import hashlib
import os

View File

@ -1,3 +1,4 @@
from __future__ import with_statement
from ConfigParser import RawConfigParser
import errno
import fcntl
@ -210,7 +211,7 @@ class Store(object):
class BandIO(object):
header_fmt = struct.Struct('<iBiB32s')
header_fmt = struct.Struct('<IBIB32s')
assert header_fmt.size == 42
def __init__(self, path, nextband, limit, bands_per_dir, capacity=100):
@ -265,7 +266,7 @@ class BandIO(object):
size, magic, hash, ns, id = self.header_fmt.unpack(data)
assert magic == 0
data = fd.read(size - self.header_fmt.size)
if crc32(data) != hash:
if crc32(data) & 0xffffffff != hash:
raise IntegrityError('Band checksum mismatch')
return data
@ -281,7 +282,7 @@ class BandIO(object):
offset += size
if lookup(ns, key):
data = fd.read(size - self.header_fmt.size)
if crc32(data) != hash:
if crc32(data) & 0xffffffff != hash:
raise IntegrityError('Band checksum mismatch')
yield ns, key, data
else:
@ -298,7 +299,7 @@ class BandIO(object):
fd.write('DARCBAND')
self.offset = 8
offset = self.offset
hash = crc32(data)
hash = crc32(data) & 0xffffffff
fd.write(self.header_fmt.pack(size, 0, hash, ns, id))
fd.write(data)
self.offset += size

View File

@ -1,3 +1,4 @@
from __future__ import with_statement
import doctest
import filecmp
import os