From 1d7b6ef655934148f6de94238a276e020a62c87e Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 20 Apr 2016 15:51:37 +0200 Subject: [PATCH] Simplify guestagent.pkg: don't use metaclass Avoid complex metaclass to define pkg.Package. It doesn't seem to work on Python 3, and simpler code works too :-) Partially implements: blueprint trove-python3 Change-Id: I880527f043fcddb11926d38b5641b3a61512e27f --- trove/guestagent/pkg.py | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/trove/guestagent/pkg.py b/trove/guestagent/pkg.py index bc4807908b..367f65e8cb 100644 --- a/trove/guestagent/pkg.py +++ b/trove/guestagent/pkg.py @@ -24,7 +24,6 @@ from tempfile import NamedTemporaryFile from oslo_log import log as logging import pexpect -import six from trove.common import exception from trove.common.exception import ProcessExecutionError @@ -80,7 +79,7 @@ class PkgConfigureError(exception.TroveError): pass -class BasePackagerMixin: +class BasePackagerMixin(object): def pexpect_kill_proc(self, child): child.delayafterclose = 1 @@ -414,17 +413,9 @@ class DebianPackagerMixin(BasePackagerMixin): % package_name) -class BasePackage(type): - - def __new__(meta, name, bases, dct): - if operating_system.get_os() == operating_system.REDHAT: - bases += (RedhatPackagerMixin, ) - else: - # The default is debian - bases += (DebianPackagerMixin,) - return super(BasePackage, meta).__new__(meta, name, bases, dct) - - -@six.add_metaclass(BasePackage) -class Package(object): - pass +if operating_system.get_os() == operating_system.REDHAT: + class Package(RedhatPackagerMixin): + pass +else: + class Package(DebianPackagerMixin): + pass