Replace deprecated library function os.popen() with subprocess

os.popen() is deprecated since python 2.6.
Resolved with use of subprocess module.

Change-Id: Ia7e19f82bedfa43cd8f98d03fb5a0bb0860d0221
Closes-Bug: #1529836
This commit is contained in:
Harshada Mangesh Kakad 2016-01-14 05:11:29 -08:00
parent 185f5fd832
commit aa3200f1cb
2 changed files with 7 additions and 4 deletions

View File

@ -35,8 +35,9 @@ metadata for the project where the docs reside::
# We ask git for the SHA checksum
# The git SHA checksum is used by "log-a-bug"
git_cmd = "/usr/bin/git log | head -n1 | cut -f2 -d' '"
gitsha = os.popen(git_cmd).read().strip('\n')
git_cmd = ["/usr/bin/git", "rev-parse", "HEAD"]
gitsha = subprocess.Popen(
git_cmd, stdout=subprocess.PIPE).communicate()[0].strip('\n')
# tag that reported bugs will be tagged with
bug_tag = "your-chosen-tag"
# source tree

View File

@ -12,6 +12,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import subprocess
import sys
import os
@ -67,8 +68,9 @@ release = '1.0'
# bug_tag: Tag for categorizing the bug. Must be set manually.
# These variables are passed to the logabug code via html_context.
giturl = u'http://git.openstack.org/cgit/openstack/openstackdocstheme/tree/doc/source'
git_cmd = "/usr/bin/git log | head -n1 | cut -f2 -d' '"
gitsha = os.popen(git_cmd).read().strip('\n')
git_cmd = ["/usr/bin/git", "rev-parse", "HEAD"]
gitsha = subprocess.Popen(
git_cmd, stdout=subprocess.PIPE).communicate()[0].strip('\n')
bug_tag = "doc-builds"
html_context = {"gitsha": gitsha, "bug_tag": bug_tag, "giturl" : giturl}