From 64b86fda18be46990bc6d29dc2aa212f5066df99 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Mon, 21 May 2012 11:09:50 -0500 Subject: Packages: Unicode-objects must be encoded before hashing Fixes a traceback in PY3K. Signed-off-by: Sol Jerome --- src/lib/Bcfg2/Server/Plugin.py | 5 +++++ src/lib/Bcfg2/Server/Plugins/Packages/Collection.py | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py index 90e39e52d..b668b7442 100644 --- a/src/lib/Bcfg2/Server/Plugin.py +++ b/src/lib/Bcfg2/Server/Plugin.py @@ -25,6 +25,11 @@ from Bcfg2.Bcfg2Py3k import Queue from Bcfg2.Bcfg2Py3k import Empty from Bcfg2.Bcfg2Py3k import Full +# make encoding available +encparse = Bcfg2.Options.OptionParser({'encoding': Bcfg2.Options.ENCODING}) +encparse.parse([]) +encoding = encparse['encoding'] + # grab default metadata info from bcfg2.conf opts = {'owner': Bcfg2.Options.MDATA_OWNER, 'group': Bcfg2.Options.MDATA_GROUP, diff --git a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py index 3ea14ce75..b2155dfa9 100644 --- a/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py +++ b/src/lib/Bcfg2/Server/Plugins/Packages/Collection.py @@ -52,7 +52,7 @@ class Collection(Bcfg2.Server.Plugin.Debuggable): @property def cachekey(self): - return md5(self.get_config()).hexdigest() + return md5(self.get_config().encode(Bcfg2.Server.Plugin.encoding)).hexdigest() def get_config(self): self.logger.error("Packages: Cannot generate config for host with " -- cgit v1.2.3-1-g7c22