summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/lib/Bcfg2/Bcfg2Py3k.py3
-rw-r--r--src/lib/Bcfg2/Server/Core.py5
-rw-r--r--src/lib/Bcfg2/Server/Plugin.py8
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Base.py5
-rw-r--r--testsuite/common.py7
5 files changed, 11 insertions, 17 deletions
diff --git a/src/lib/Bcfg2/Bcfg2Py3k.py b/src/lib/Bcfg2/Bcfg2Py3k.py
index a4441946b..be5175e62 100644
--- a/src/lib/Bcfg2/Bcfg2Py3k.py
+++ b/src/lib/Bcfg2/Bcfg2Py3k.py
@@ -101,8 +101,7 @@ except:
try:
reduce = reduce
except NameError:
- import functools
- reduce = functools.reduce
+ from functools import reduce
try:
from collections import MutableMapping
diff --git a/src/lib/Bcfg2/Server/Core.py b/src/lib/Bcfg2/Server/Core.py
index d518e0e92..f39453edd 100644
--- a/src/lib/Bcfg2/Server/Core.py
+++ b/src/lib/Bcfg2/Server/Core.py
@@ -14,12 +14,9 @@ import Bcfg2.settings
import Bcfg2.Server
import Bcfg2.Logger
import Bcfg2.Server.FileMonitor
-from Bcfg2.Bcfg2Py3k import xmlrpclib
+from Bcfg2.Bcfg2Py3k import xmlrpclib, reduce
from Bcfg2.Server.Plugin import PluginInitError, PluginExecutionError
-if sys.hexversion >= 0x03000000:
- from functools import reduce
-
try:
import psyco
psyco.full()
diff --git a/src/lib/Bcfg2/Server/Plugin.py b/src/lib/Bcfg2/Server/Plugin.py
index f841cef22..822f2894a 100644
--- a/src/lib/Bcfg2/Server/Plugin.py
+++ b/src/lib/Bcfg2/Server/Plugin.py
@@ -10,7 +10,8 @@ import threading
import lxml.etree
import Bcfg2.Server
import Bcfg2.Options
-from Bcfg2.Bcfg2Py3k import ConfigParser, CmpMixin
+from Bcfg2.Bcfg2Py3k import ConfigParser, CmpMixin, reduce, Queue, Empty, \
+ Full, cPickle
try:
import django
@@ -18,11 +19,6 @@ try:
except ImportError:
has_django = False
-# py3k compatibility
-if sys.hexversion >= 0x03000000:
- from functools import reduce
-from Bcfg2.Bcfg2Py3k import Queue, Empty, Full, cPickle
-
# 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/Base.py b/src/lib/Bcfg2/Server/Plugins/Base.py
index 389ca7a95..2020f7795 100644
--- a/src/lib/Bcfg2/Server/Plugins/Base.py
+++ b/src/lib/Bcfg2/Server/Plugins/Base.py
@@ -3,10 +3,7 @@
import copy
import lxml.etree
import sys
-# py3k compatibility
-if sys.hexversion >= 0x03000000:
- from functools import reduce
-
+from Bcfg2.Bcfg2Py3k import reduce
import Bcfg2.Server.Plugin
diff --git a/testsuite/common.py b/testsuite/common.py
index 5b1799d91..42efe9fd6 100644
--- a/testsuite/common.py
+++ b/testsuite/common.py
@@ -2,7 +2,12 @@ import os
import sys
import unittest
from mock import patch, MagicMock, _patch, DEFAULT
-from functools import wraps
+
+try:
+ from functools import wraps
+except ImportError:
+ def wraps(wrapped):
+ return lambda f: f
datastore = "/"