From 804da5f03da352387921081d068927ade3b78fcb Mon Sep 17 00:00:00 2001 From: Yatin Kumbhare Date: Tue, 5 Jan 2016 18:09:37 +0530 Subject: [PATCH] Fix for the deprecated library function os.popen() is deprecated since version 2.6. Resolved with use of subprocess module. Change-Id: Ie7e0cf06fb5f6a40984a24b3c9123187c0a3a3cc --- api-quick-start/source/conf.py | 12 +++++++----- firstapp/source/conf.py | 12 +++++++----- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/api-quick-start/source/conf.py b/api-quick-start/source/conf.py index 36b7b18f0..5c12e397c 100644 --- a/api-quick-start/source/conf.py +++ b/api-quick-start/source/conf.py @@ -20,10 +20,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os - - import openstackdocstheme +import os +import subprocess # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -73,8 +72,11 @@ release = '0.1' # bug_project: Project to file bugs against. # These variables are passed to the logabug code via html_context. giturl = u'http://git.openstack.org/cgit/openstack/api-site/tree/api-quick-start/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", "log", "-1"] +last_commit = subprocess.Popen(git_cmd, stdout=subprocess.PIPE) +first_line_cmd = ["head", "-n1"] +gitsha = subprocess.Popen(first_line_cmd, stdin=last_commit.stdout, + stdout=subprocess.PIPE).communicate()[0].split()[-1].strip() html_context = {"gitsha": gitsha, "bug_tag": bug_tag, "giturl": giturl, "bug_project": "openstack-api-site"} diff --git a/firstapp/source/conf.py b/firstapp/source/conf.py index 546159cd4..f45313660 100644 --- a/firstapp/source/conf.py +++ b/firstapp/source/conf.py @@ -20,10 +20,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os - - import openstackdocstheme +import os +import subprocess # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -79,8 +78,11 @@ release = '0.1' # bug_project: Project to file bugs against. # These variables are passed to the logabug code via html_context. giturl = u'http://git.openstack.org/cgit/openstack/api-site/tree/firstapp/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", "log", "-1"] +last_commit = subprocess.Popen(git_cmd, stdout=subprocess.PIPE) +first_line_cmd = ["head", "-n1"] +gitsha = subprocess.Popen(first_line_cmd, stdin=last_commit.stdout, + stdout=subprocess.PIPE).communicate()[0].split()[-1].strip() html_context = {"gitsha": gitsha, "bug_tag": bug_tag, "giturl": giturl, "bug_project": "openstack-api-site"}