Replace deprecated library function os.popen() with subprocess

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

Change-Id: If98222db21fb84f30de7fb3f7dc5d2dc229d3b37
Closes-Bug: #1529836
This commit is contained in:
LiuNanke 2016-01-09 19:49:38 +08:00
parent 818b1a030f
commit 239e1f629b

View File

@ -13,6 +13,7 @@
import sys import sys
import os import os
import subprocess
BASE_DIR = os.path.dirname(os.path.abspath(__file__)) BASE_DIR = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", "..")) ROOT = os.path.abspath(os.path.join(BASE_DIR, "..", ".."))
@ -152,8 +153,10 @@ html_theme_options = {
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format. # using the given strftime format.
#html_last_updated_fmt = '%b %d, %Y' #html_last_updated_fmt = '%b %d, %Y'
git_cmd = "git log --pretty=format:'%ad, commit %h' --date=local -n1" git_cmd = ["git", "log", "--pretty=format:'%ad, commit %h'", "--date=local",
html_last_updated_fmt = os.popen(git_cmd).read() "-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 # If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities. # typographically correct entities.