#!/usr/bin/env pythonimportosimporturllibimporthashlibimportsysdefmd5Checksum(file_path):withopen(file_path,'rb')asfh:m=hashlib.md5()whileTrue:data=fh.read(8192)ifnotdata:breakm.update(data)returnm.hexdigest()if__name__=="__main__":url,md5sum,destination_path=sys.argv[1:]urllib.urlretrieve(url,destination_path)computed_md5sum=md5Checksum(destination_path)ifcomputed_md5sum!=md5sum:os.remove(destination_path)raiseException('MD5 mismatch. MD5 of downloaded file is %s, Specified MD5 is %s.'%(computed_md5sum,md5sum))