Replace md5 module with hashlib
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Wed, 13 Mar 2019 14:11:13 +0300
changeset 2540 fca79ca84272
parent 2539 bcadc7f465ee
child 2541 92f0980888e8
Replace md5 module with hashlib

fix following pylint error:

************* Module connectors.ConnectorBase
connectors/ConnectorBase.py:7: [W1648(bad-python3-import), ] Module moved in Python 3
************* Module runtime.PLCObject
runtime/PLCObject.py:33: [W1648(bad-python3-import), ] Module moved in Python 3
connectors/ConnectorBase.py
runtime/PLCObject.py
--- a/connectors/ConnectorBase.py	Wed Mar 13 11:51:40 2019 +0300
+++ b/connectors/ConnectorBase.py	Wed Mar 13 14:11:13 2019 +0300
@@ -4,7 +4,7 @@
 # See COPYING file for copyrights details.
 
 from __future__ import absolute_import
-import md5
+import hashlib
 
 
 class ConnectorBase(object):
@@ -12,7 +12,7 @@
     chuncksize = 1024*1024
 
     def BlobFromFile(self, filepath, seed):
-        s = md5.new()
+        s = hashlib.new('md5')
         s.update(seed)
         blobID = self.SeedBlob(seed)
         with open(filepath, "rb") as f:
@@ -22,3 +22,4 @@
                     return blobID
                 blobID = self.AppendChunkToBlob(chunk, blobID)
                 s.update(chunk)
+
--- a/runtime/PLCObject.py	Wed Mar 13 11:51:40 2019 +0300
+++ b/runtime/PLCObject.py	Wed Mar 13 14:11:13 2019 +0300
@@ -30,7 +30,7 @@
 import traceback
 import shutil
 from time import time
-import md5
+import hashlib
 from tempfile import mkstemp
 from functools import wraps, partial
 from six.moves import xrange
@@ -465,7 +465,7 @@
 
     @RunInMain
     def SeedBlob(self, seed):
-        blob = (mkstemp(dir=self.tmpdir) + (md5.new(),))
+        blob = (mkstemp(dir=self.tmpdir) + (hashlib.new('md5'),))
         _fobj, _path, md5sum = blob
         md5sum.update(seed)
         newBlobID = md5sum.digest()