Since md5 was deprecated in Python 2.5 warnings have been issued, this is just a little annoying. The attached patch fixes this, there were several approaches I could have taken, but I felt that this was the best one. Tested with python 2.4 (RHEL 5) and python 2.6 (RHEL 6). Input is welcome, -Erinn
From 2304b613f495498a3513edae015e8c9100a01985 Mon Sep 17 00:00:00 2001 From: Erinn Looney-Triggs <erinn.looneytriggs@xxxxxxxxx> Date: Mon, 27 Aug 2012 16:00:46 -0800 Subject: [PATCH] Reworked bits of filetracker to work with hashlib and be backward compatible. --- func/minion/modules/filetracker.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/func/minion/modules/filetracker.py b/func/minion/modules/filetracker.py index d4f7f3a..6480246 100644 --- a/func/minion/modules/filetracker.py +++ b/func/minion/modules/filetracker.py @@ -23,7 +23,12 @@ from stat import * import fnmatch import glob import os -import md5 + +#hashlib was introduced in 2.5 md5 is deprecated as of 2.5 +try: + import hashlib +except ImportError: + import md5 # defaults CONFIG_FILE='/etc/func/modules/filetracker.conf' @@ -235,8 +240,13 @@ class FileTracker(func_module.FuncModule): Returns an md5 hash for an object with read() method. credit: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/266486 """ - - m = md5.new() + + #hashlib was introduced in 2.5 md5 is deprecated as of 2.5 + try: + m = hashlib.md5() + except NameError: + m = md5.new() + while True: d = fobj.read(8096) if not d: -- 1.7.11.4
Attachment:
signature.asc
Description: OpenPGP digital signature
_______________________________________________ func mailing list func@xxxxxxxxxxxxxxxxxxxxxx https://lists.fedorahosted.org/mailman/listinfo/func