From e5749bec65deabf567dc80a32b41cfcee79fbe64 Mon Sep 17 00:00:00 2001 From: kairoaraujo Date: Wed, 17 Feb 2016 12:21:39 -0200 Subject: [PATCH] hacking: check for deprecated os.open() Add hacking check for deprecated library function os.popen(). This bug was reported https://bugs.launchpad.net/tempest/+bug/1529836 and this hacking prevents new os.popen() in the code. Change-Id: I124b9f86ffc6eba268c99ad9834686f55fd857c3 --- HACKING.rst | 2 ++ nova_powervm/hacking/checks.py | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/HACKING.rst b/HACKING.rst index fb9832f3..2acac58d 100644 --- a/HACKING.rst +++ b/HACKING.rst @@ -10,6 +10,8 @@ Nova-PowerVM Specific Commandments - Follow the Nova HACKING.rst - [P301] LOG.warn() is not allowed. Use LOG.warning() +- [P302] Deprecated library function os.popen() + Creating Unit Tests ------------------- diff --git a/nova_powervm/hacking/checks.py b/nova_powervm/hacking/checks.py index 63d47652..7c497f2c 100644 --- a/nova_powervm/hacking/checks.py +++ b/nova_powervm/hacking/checks.py @@ -25,6 +25,21 @@ def no_log_warn(logical_line, filename): yield(0, 'P301 Use LOG.warning() rather than LOG.warn()') +def no_os_popen(logical_line): + """Disallow 'os.popen(' + + Deprecated library function os.popen() Replace it using subprocess + https://bugs.launchpad.net/tempest/+bug/1529836 + + P302 + """ + + if 'os.popen(' in logical_line: + yield(0, 'P302 Deprecated library function os.popen(). ' + 'Replace it using subprocess module. ') + + def factory(register): register(no_log_warn) + register(no_os_popen) checks.factory(register)