#!/usr/bin/env python
-import sys, os, glob, subprocess, time, sha
+import sys, os, glob, subprocess, time
from bup import options, git
from bup.helpers import *
wantsum = f.read(20)
assert(len(wantsum) == 20)
f.seek(0)
- sum = sha.sha()
+ sum = Sha1()
for b in chunkyreader(f, os.fstat(f.fileno()).st_size - 20):
sum.update(b)
if sum.digest() != wantsum:
#!/usr/bin/env python
-import sys, math, struct, glob, sha
+import sys, math, struct, glob
from bup import options, git
from bup.helpers import *
def do_midx(outdir, outfilename, infilenames):
if not outfilename:
assert(outdir)
- sum = sha.sha('\0'.join(infilenames)).hexdigest()
+ sum = Sha1('\0'.join(infilenames)).hexdigest()
outfilename = '%s/midx-%s.midx' % (outdir, sum)
inp = []
-import os, errno, zlib, time, sha, subprocess, struct, stat, re, tempfile
+import os, errno, zlib, time, subprocess, struct, stat, re, tempfile
import heapq
from bup.helpers import *
def calc_hash(type, content):
header = '%s %d\0' % (type, len(content))
- sum = sha.sha(header)
+ sum = Sha1(header)
sum.update(content)
return sum.digest()
# calculate the pack sha1sum
f.seek(0)
- sum = sha.sha()
+ sum = Sha1()
while 1:
b = f.read(65536)
sum.update(b)
else:
return oldhook(exctype, value, traceback)
sys.excepthook = newhook
+
+
+# hashlib is only available in python 2.5 or higher, but the 'sha' module
+# produces a DeprecationWarning in python 2.6 or higher. We want to support
+# python 2.4 and above without any stupid warnings, so let's try using hashlib
+# first, and downgrade if it fails.
+try:
+ import hashlib
+except ImportError:
+ import sha
+ Sha1 = sha.sha
+else:
+ Sha1 = hashlib.sha1