Salome HOME
Ajout pour correction checksum de MT
authoresy <emmanuel.streby@opencascade.com>
Wed, 10 Jun 2020 15:49:19 +0000 (17:49 +0200)
committeresy <emmanuel.streby@opencascade.com>
Wed, 10 Jun 2020 15:49:19 +0000 (17:49 +0200)
InterfaceQT4/editorSsIhm.py

index 69bd9d6bbd32f952ab71256aca22bd64557b19a4..8d0bb0a3cc8d3848ee187daf5c5549193bc86d62 100644 (file)
@@ -481,15 +481,23 @@ class JDCEditorSsIhm :
     def getChecksum(self,texte):
     #---------------------------#
         try :
+           import haslib
            newtexte=texte.replace('"','\\"')
-           commande='echo "'+newtexte+'"|md5sum'
-           a=os.popen(commande)
-           checksum=a.read()
-           a.close()
-        except :
-           checksum='Fichier trop long \n'
-        ligne="#CHECKSUM:"+checksum[0:-1]+":FIN CHECKSUM"
-        return ligne
+           hash_checksum = hashlib.md5()
+           hash_checksum.update(newtexte.encode('utf-8'))
+           checksum = hash_checksum.hexdigest()
+           ligne = ligne="#CHECKSUM:"+checksum+":FIN CHECKSUM"
+        except : 
+           try :
+              newtexte=texte.replace('"','\\"')
+              commande='echo "'+newtexte+'"|md5sum'
+              a=os.popen(commande)
+              checksum=a.read()
+              a.close()
+           except :
+              checksum='Fichier trop long \n'
+           ligne="#CHECKSUM:"+checksum[0:-1]+":FIN CHECKSUM"
+           return ligne
 
     #----------------------#
     def getDico(self):