Changeset 7013


Ignore:
Timestamp:
May 11, 2009, 4:18:30 PM (11 years ago)
Author:
rwilson
Message:

Made md5/hashlib changeover transparent. hashlib used if available.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/system_tools.py

    r6904 r7013  
    1010import getpass
    1111import tarfile
    12 import md5
     12try:
     13    import hashlib
     14except ImportError:
     15    import md5 as hashlib
    1316
    1417
     
    478481def get_file_hexdigest(filename, blocksize=1024*1024*10):
    479482    '''Get a hex digest of a file.'''
    480    
    481     m = md5.new()
     483
     484    if hashlib.__name__ == 'hashlib':
     485        m = hashlib.md5()       # new - 'hashlib' module
     486    else:
     487        m = hashlib.new()       # old - 'md5' module - remove once py2.4 gone
    482488    fd = open(filename, 'r')
    483489           
Note: See TracChangeset for help on using the changeset viewer.