Exemple #1
0
def verifySingleCommit(commit, bundle):
    with DebugInfo('Verify commit: %04d-%s' % (commit['CommitID'],commit['Name'])) as d:
        actualHash = recalculateCommitMD5(commit, bundle)
        expectHash = commit['MD5']
        if actualHash != expectHash:
            from pclib import byteshex
            message = 'Verify failed: actual %s expect %s' % (byteshex.encode(actualHash), byteshex.encode(expectHash))
            d.result = message
            return message
        else:
            d.result = 'Success'
Exemple #2
0
def recalculateCommitMD5(commit, bundle):
    with DebugInfo('Recalculating commit md5') as d:
        from histo.server.get import openDataCodes
        from pclib import hashstream
        hasher = hashstream('md5')
        with openDataCodes(bundle, commit) as f:
            from pclib import copystream
            copystream(f, hasher)
        result = hasher.digest()
        from pclib import byteshex
        d.result = byteshex.encode(result)
        return result