Add note in README about Python 3 changes

Add a node that explains that for Python 3 you'll need to add a
.decode() function in the gitsha command. Also, note that you
need to import subprocess in the conf.py file.

Change-Id: I1eb42738be74de96fae0940f3e97283351602e95
This commit is contained in:
Leif Madsen 2017-01-30 11:50:16 -05:00 committed by Anne Gentle
parent b0e3e8a6a4
commit a4a2ed7f99
3 changed files with 14 additions and 4 deletions

View File

@ -45,7 +45,8 @@ Then modify your Sphinx settings in ``conf.py`` to include::
html_theme_path = [openstackdocstheme.get_html_theme_path()]
Also, you must include these variables so that the "Log a bug" link sends
metadata for the project where the docs reside::
metadata for the project where the docs reside. You'll also need to add
``import subprocess`` to the top of your ``conf.py`` file::
# We ask git for the SHA checksum
# The git SHA checksum is used by "log-a-bug"
@ -61,8 +62,17 @@ metadata for the project where the docs reside::
# Must set this variable to include year, month, day, hours, and minutes.
html_last_updated_fmt = '%Y-%m-%d %H:%M'
.. note::
If you're using Python 3 to build, you'll need to adjust the ``gitsha``
command to add a ``.decode('utf-8')`` option.
::
gitsha = subprocess.Popen(
git_cmd, stdout=subprocess.PIPE).communicate()[0].decode('utf-8').strip('\n')
* Free software: Apache License, Version 2.0
* Release notes: http://docs.openstack.org/releasenotes/openstackdocstheme/
* Source: http://git.openstack.org/cgit/openstack/openstackdocstheme
* Bugs: http://bugs.launchpad.net/openstack-manuals

View File

@ -34,4 +34,4 @@ server.obj:
required: true
type: object
description: |
The server object.
The server object.

View File

@ -72,7 +72,7 @@ giturl = u'http://git.openstack.org/cgit/openstack/openstackdocstheme/tree/doc/s
git_cmd = ["/usr/bin/git", "rev-parse", "HEAD"]
try:
gitsha = subprocess.Popen(
git_cmd, stdout=subprocess.PIPE).communicate()[0].strip('\n')
git_cmd, stdout=subprocess.PIPE).communicate()[0].decode('utf-8').strip('\n')
except OSError:
warnings.warn('Cannot get gitsha from git repository. Setting to None')
gitsha = None