Replace deprecated library function os.popen() with subprocess

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

Change-Id: I261a2c6578b2f6a57a61bb672f38c6d9d6169c3f
Closes-Bug: #1529836
This commit is contained in:
Harshada Mangesh Kakad 2016-01-14 09:19:40 -08:00
parent 9e18831b39
commit 8b0510e81a
1 changed files with 4 additions and 3 deletions

View File

@ -20,7 +20,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.
import os
import subprocess
# import sys
@ -74,8 +74,9 @@ release = '1.0.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/i18n/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')
html_context = {"gitsha": gitsha, "bug_tag": bug_tag,
"giturl": giturl}