diff --git a/api-guide/source/conf.py b/api-guide/source/conf.py index 0b805bbf8dda..5ced3d297365 100644 --- a/api-guide/source/conf.py +++ b/api-guide/source/conf.py @@ -19,7 +19,7 @@ # serve to show the default. # import sys -import os +import subprocess import openstackdocstheme @@ -81,10 +81,15 @@ release = '2.1.0' # bug_project: Launchpad project to file bugs against. # These variables are passed to the logabug code via html_context. giturl = u'http://git.openstack.org/cgit/openstack/nova/tree/api-guide/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] + + # source tree -pwd = os.popen("pwd").read().strip('\n') +pwd = subprocess.Popen( + "pwd", stdout=subprocess.PIPE).communicate()[0].strip('\n') + # html_context allows us to pass arbitrary values into the html template html_context = {"pwd": pwd, "gitsha": gitsha, diff --git a/doc/source/conf.py b/doc/source/conf.py index c691fcbd63ce..b0ba05ef7cf5 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -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 @@ -194,8 +195,10 @@ html_static_path = ['_static'] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. #html_last_updated_fmt = '%b %d, %Y' -git_cmd = "git log --pretty=format:'%ad, commit %h' --date=local -n1" -html_last_updated_fmt = os.popen(git_cmd).read() +git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local", + "-n1"] +html_last_updated_fmt = subprocess.Popen( + git_cmd, stdout=subprocess.PIPE).communicate()[0] # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities.