summaryrefslogtreecommitdiffstats
path: root/src/setup_common.py
diff options
context:
space:
mode:
authorSlavek Kabrda <bkabrda@redhat.com>2015-01-21 12:57:35 +0100
committerDavid Sommerseth <davids@redhat.com>2015-02-03 21:16:25 +0100
commit5cc3d02060f67317049b6e0549c87a407e030e61 (patch)
tree15174b46cabd9ea08a1c9c35ebb831018577f00f /src/setup_common.py
parent9fa1352cd540aa69dd8b59e56de9b8020563e545 (diff)
downloadpython-dmidecode-5cc3d02060f67317049b6e0549c87a407e030e61.tar.gz
python-dmidecode-5cc3d02060f67317049b6e0549c87a407e030e61.tar.xz
python-dmidecode-5cc3d02060f67317049b6e0549c87a407e030e61.zip
Port to Python 3 while maintaining compatibility with Python >= 2.6
Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'src/setup_common.py')
-rw-r--r--src/setup_common.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/setup_common.py b/src/setup_common.py
index 209ccef..aec1f9b 100644
--- a/src/setup_common.py
+++ b/src/setup_common.py
@@ -26,17 +26,19 @@
# are deemed to be part of the source code.
#
-import commands, sys
+import subprocess, sys
+if sys.version_info[0] < 3:
+ import commands as subprocess
from os import path as os_path
from distutils.sysconfig import get_python_lib
# libxml2 - C flags
def libxml2_include(incdir):
- (res, libxml2_cflags) = commands.getstatusoutput("xml2-config --cflags")
+ (res, libxml2_cflags) = subprocess.getstatusoutput("xml2-config --cflags")
if res != 0:
- print "Could not build python-dmidecode."
- print "Could not run xml2-config, is libxml2 installed?"
- print "Also the development libraries?"
+ print("Could not build python-dmidecode.")
+ print("Could not run xml2-config, is libxml2 installed?")
+ print("Also the development libraries?")
sys.exit(1)
# Parse the xml2-config --cflags response
@@ -52,11 +54,11 @@ def libxml2_lib(libdir, libs):
if os_path.exists("/etc/debian_version"): #. XXX: Debian Workaround...
libdir.append("/usr/lib/pymodules/python%d.%d"%sys.version_info[0:2])
- (res, libxml2_libs) = commands.getstatusoutput("xml2-config --libs")
+ (res, libxml2_libs) = subprocess.getstatusoutput("xml2-config --libs")
if res != 0:
- print "Could not build python-dmidecode."
- print "Could not run xml2-config, is libxml2 installed?"
- print "Also the development libraries?"
+ print("Could not build python-dmidecode.")
+ print("Could not run xml2-config, is libxml2 installed?")
+ print("Also the development libraries?")
sys.exit(1)
# Parse the xml2-config --libs response