Red Hat Bugzilla – Bug 484657
hts uses code deprecated in python 2.6
Last modified: 2014-03-25 20:56:14 EDT
Description of problem:
Some of the code in hts will need to be updated for python 2.6. Specifically, the Exception.message member is deprecated, as is the popen2 module (use subprocesses instead).
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Try running hts on a system with python 2.6.
Actual results: Deprecation warnings.
I've only tested the parts related to the cpuscaling test.
Created attachment 331301 [details]
Removed all references to the 'exceptions' module because, according to Python's docs, "this module never needs to be imported explicitly". Its contents are always available in the global namespace.
Works around Exception.message warning by adding a 'message' property in the subclass.
I didn't fix the popen2 warning, since its replacement is too new for RHEL4 (added in python 2.4; distro has python 2.3).
Created attachment 379692 [details]
command.py patch replacing popen2 with subprocess module
also uses previous patch to account for exeptions changes in python 2.6.
Created attachment 379694 [details]
Makefile patch encoding RHEL version
This Makefile patch makes the v7 build process RHEL version-specific via a new varible V7_RHEL_VERSION. This is necessary since v7 coverage will now span RHEL4 through RHEL6, which means Python versions 2.3 through 2.6. In this cases, the popen2 module is depreciated in Python 2.6 in favor of the subprocess module, which is not available in Python 2.3.
This patch also changes the build process to use RHEL version-specific v7.spec and rpm source tar files.
Created attachment 379696 [details]
v7/v7/Makefile patch to install multiple command.py versions
This patch changes the v7 library Makefile to install the correct version of the Command wrapper class for subprocesses/commands. For RHEL 4, the old popen2-based version will be used (command-popen2.py). For later RHEL releases, the revised subprocess-based version will be used (command.py).
Created attachment 379698 [details]
build utility script changes for new Make changes
The build utility script will be changed to build a single RHEL release-specific v7.
Created attachment 379700 [details]
memory test patch removing popen2 reference
The memory test is changed to use the v7/command.py wrapper.
FWIW, it might be easier to handle the multiple modules entirely in Python, without relying the build system. Just try to import subprocess, and if it fails, fall back to popen2. This is simple, and more tolerant of unexpected environments.
Created attachment 382792 [details]
command.py pach on R21 fixing lack of newlines in output
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.