connectors/ConnectorBase.py
author Edouard Tisserant <edouard.tisserant@gmail.com>
Thu, 07 Mar 2019 21:57:18 +0100
changeset 2491 362039519454
parent 2487 6a4f9a061994
child 2492 7dd551ac2fa0
permissions -rw-r--r--
Added stub axis_s type in EtherLAB CiA402 support code, until Motion Contol Library comes back
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# See COPYING file for copyrights details.

import md5

class ConnectorBase(object):

    #chuncksize = 16384
    chuncksize = 1024*1024
    def BlobFromFile(self, filepath, seed):
        s = md5.new()
        s.update(seed)
        blobID = self.SeedBlob(seed)
        with open(filepath, "rb") as f:
            while blobID == s.digest():
                chunk = f.read(self.chuncksize) 
                if len(chunk) == 0: return blobID
                blobID = self.AppendChunkToBlob(chunk, blobID)
                s.update(chunk)