/venus

To download this project, use:
bzr branch http://golem.ph.utexas.edu/~distler/code/venus/

« back to all changes in this revision

Viewing changes to planet/spider.py

  • Committer: Jacques Distler
  • Date: 2009-01-05 02:55:13 UTC
  • Revision ID: distler@golem.ph.utexas.edu-20090105025513-djk2unyyct87mn9x
Use hashlib instead of md5
  
Python 2.6 complains about md5.
Hashlib works for  python >= 2.5.

Show diffs side-by-side

added added

removed removed

44
44
        parts=filename.split(',')
45
45
        for i in range(len(parts),0,-1):
46
46
            if len(','.join(parts[:i])) < 220:
47
 
                import md5
 
47
                import hashlib
48
48
                filename = ','.join(parts[:i]) + ',' + \
49
 
                    md5.new(','.join(parts[i:])).hexdigest()
 
49
                    hashlib.md5(','.join(parts[i:])).hexdigest()
50
50
                break
51
51
  
52
52
    return os.path.join(directory, filename)
277
277
    xdoc.unlink()
278
278
 
279
279
def httpThread(thread_index, input_queue, output_queue, log):
280
 
    import httplib2, md5
 
280
    import httplib2, hashlib
281
281
    from httplib import BadStatusLine
282
282
 
283
283
    h = httplib2.Http(config.http_cache_directory())
312
312
            (resp, content) = h.request(idna, 'GET', headers=headers)
313
313
 
314
314
            # unchanged detection
315
 
            resp['-content-hash'] = md5.new(content or '').hexdigest()
 
315
            resp['-content-hash'] = hashlib.md5(content or '').hexdigest()
316
316
            if resp.status == 200:
317
317
                if resp.fromcache:
318
318
                    resp.status = 304