From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 521091381F3 for ; Mon, 23 Sep 2013 01:06:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0031DE0966; Mon, 23 Sep 2013 01:06:41 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 887C8E0966 for ; Mon, 23 Sep 2013 01:06:40 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5E40233EB6F for ; Mon, 23 Sep 2013 01:06:39 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id EE414E468F for ; Mon, 23 Sep 2013 01:06:36 +0000 (UTC) From: "Devan Franchini" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Devan Franchini" Message-ID: <1379896809.8ab980c797303dce6c0ce009d9be28d18f8c0306.twitch153@gentoo> Subject: [gentoo-commits] proj/webapp-config:experimental commit in: WebappConfig/ X-VCS-Repository: proj/webapp-config X-VCS-Files: WebappConfig/compat.py X-VCS-Directories: WebappConfig/ X-VCS-Committer: twitch153 X-VCS-Committer-Name: Devan Franchini X-VCS-Revision: 8ab980c797303dce6c0ce009d9be28d18f8c0306 X-VCS-Branch: experimental Date: Mon, 23 Sep 2013 01:06:36 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 49e0c58d-8b0e-4f05-a00a-6dc96e47e98c X-Archives-Hash: d1d9300594d930b36a36c0da24a8a638 commit: 8ab980c797303dce6c0ce009d9be28d18f8c0306 Author: Devan Franchini hotmail com> AuthorDate: Mon Sep 23 00:40:09 2013 +0000 Commit: Devan Franchini gentoo org> CommitDate: Mon Sep 23 00:40:09 2013 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/webapp-config.git;a=commit;h=8ab980c7 WebappConfig/compat.py: Adds compatibility check for file_md5(). When the file_md5() function is called in python3.2+ a hash file is supposed to be created, and on a if an object is unicode, it needs to be encoded prior to hashing. In order to do this, a file called compat.py has a function in it called create_md5(); this function checks the hexidecimal python version and based on the version, either encodes the file before it hashes, or simply returns the md5 hash. --- WebappConfig/compat.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/WebappConfig/compat.py b/WebappConfig/compat.py new file mode 100644 index 0000000..536bb2a --- /dev/null +++ b/WebappConfig/compat.py @@ -0,0 +1,27 @@ +#!/usr/bin/python -O +# +# /usr/sbin/webapp-config +# Python script for managing the deployment of web-based +# applications +# +# Originally written for the Gentoo Linux distribution +# +# Copyright (c) 1999-2007 Authors +# Released under v2 of the GNU GPL +# +# Author(s) Stuart Herbert +# Renat Lumpau +# Gunnar Wrobel +# +# ======================================================================== + +import hashlib, os, os.path, sys + +def create_md5(filename): + if hex(sys.hexversion) >= '0x3020000': + filename = open(filename).read() + encoded_file = filename.encode('utf8') + return str(hashlib.md5(encoded_file).hexdigest()) + else: + return str(hashlib.md5(open(filename).read()).hexdigest()) +