[master 2/5] New method to compute md5 hash of file
vojtechtrefny
installerbot-noreply at redhat.com
Mon Mar 16 12:28:59 UTC 2015
From: Vojtech Trefny <vtrefny at redhat.com>
Signed-off-by: Vojtech Trefny <vtrefny at redhat.com>
---
blivet/util.py | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/blivet/util.py b/blivet/util.py
index 5c13858..6534918 100644
--- a/blivet/util.py
+++ b/blivet/util.py
@@ -9,6 +9,7 @@
import sys
import tempfile
import uuid
+import hashlib
from decimal import Decimal
from contextlib import contextmanager
@@ -357,6 +358,18 @@ def insert_colons(a_string):
else:
return suffix
+def md5_file(filename):
+
+ f = open(filename, "rb")
+ md5 = hashlib.md5()
+
+ block = f.read(65536)
+ while block:
+ md5.update(block)
+ block = f.read(65536)
+
+ return md5.hexdigest()
+
class ObjectID(object):
"""This class is meant to be extended by other classes which require
an ID which is preserved when an object copy is made.
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/ba14eb929f9d04fb140e3deda85cf3b9b3e0d09c
More information about the anaconda-patches
mailing list