#!/usr/bin/python
# -*- coding: UTF-8 -*-
import hashlib
import subprocess
import sys, os
_FILE_SLIM=100*1024*1024
def File_md5(filepath):
calltimes = 0
hmd5 = hashlib.md5()
fp = open(filepath, "rb")
f_size = os.stat(filepath).st_size
if f_size > _FILE_SLIM:
while (f_size > _FILE_SLIM):
hmd5.update(fp.read(_FILE_SLIM))
f_size /= _FILE_SLIM
calltimes += 1
if (f_size > 0) and (f_size <= _FILE_SLIM):
hmd5.update(fp.read())
else:
hmd5.update(fp.read())
return hmd5.hexdigest()