connectors/ConnectorBase.py
changeset 2550 f2af2a655868
parent 2542 a3ec35ee94e7
child 2621 af09744a468e
equal deleted inserted replaced
2530:02d09fc6eb90 2550:f2af2a655868
     2 # -*- coding: utf-8 -*-
     2 # -*- coding: utf-8 -*-
     3 
     3 
     4 # See COPYING file for copyrights details.
     4 # See COPYING file for copyrights details.
     5 
     5 
     6 from __future__ import absolute_import
     6 from __future__ import absolute_import
     7 import md5
     7 import hashlib
     8 
     8 
     9 
     9 
    10 class ConnectorBase(object):
    10 class ConnectorBase(object):
    11 
    11 
    12     chuncksize = 1024*1024
    12     chuncksize = 1024*1024
    13 
    13 
    14     def BlobFromFile(self, filepath, seed):
    14     def BlobFromFile(self, filepath, seed):
    15         s = md5.new()
    15         s = hashlib.new('md5')
    16         s.update(seed)
    16         s.update(seed)
    17         blobID = self.SeedBlob(seed)
    17         blobID = self.SeedBlob(seed)
    18         with open(filepath, "rb") as f:
    18         with open(filepath, "rb") as f:
    19             while blobID == s.digest():
    19             while blobID == s.digest():
    20                 chunk = f.read(self.chuncksize)
    20                 chunk = f.read(self.chuncksize)