Drop python 2.6 workaround
Remove check_output that is in python 2.7 and newer but not in python 2.6. Thus, we do not support python 2.6 anymore. Change-Id: Ie953ce43d792b95e348a55fea4665b1ef59b468d
This commit is contained in:
parent
7c9c21f5e5
commit
bb3d68fba8
|
@ -19,7 +19,6 @@ import sys
|
|||
import yaml
|
||||
|
||||
import os_doc_tools
|
||||
from os_doc_tools.common import check_output # noqa
|
||||
|
||||
DEVNULL = open(os.devnull, 'wb')
|
||||
|
||||
|
@ -59,8 +58,8 @@ def generate_heading(os_command, api_name, title, os_file):
|
|||
"""
|
||||
|
||||
try:
|
||||
version = check_output([os_command, "--version"],
|
||||
stderr=subprocess.STDOUT)
|
||||
version = subprocess.check_output([os_command, "--version"],
|
||||
stderr=subprocess.STDOUT)
|
||||
except OSError as e:
|
||||
if e.errno == os.errno.ENOENT:
|
||||
print("Command %s not found, aborting." % os_command)
|
||||
|
@ -279,8 +278,8 @@ def generate_command(os_command, os_file):
|
|||
:param os_file: open filehandle for output of DocBook file
|
||||
"""
|
||||
|
||||
help_lines = check_output([os_command, "--help"],
|
||||
stderr=DEVNULL).split('\n')
|
||||
help_lines = subprocess.check_output([os_command, "--help"],
|
||||
stderr=DEVNULL).split('\n')
|
||||
|
||||
ignore_next_lines = False
|
||||
next_line_screen = True
|
||||
|
@ -402,7 +401,7 @@ def generate_subcommand(os_command, os_subcommand, os_file, extra_params,
|
|||
else:
|
||||
args.append("help")
|
||||
args.append(os_subcommand)
|
||||
help_lines = check_output(args, stderr=DEVNULL)
|
||||
help_lines = subprocess.check_output(args, stderr=DEVNULL)
|
||||
|
||||
if 'positional arguments' in help_lines.lower():
|
||||
index = help_lines.lower().index('positional arguments')
|
||||
|
@ -510,14 +509,15 @@ def generate_subcommands(os_command, os_file, subcommands, extra_params,
|
|||
if subcommands == 'complete':
|
||||
subcommands = []
|
||||
args.append('complete')
|
||||
for line in [x.strip() for x in check_output(args).split('\n')
|
||||
for line in [x.strip() for x in
|
||||
subprocess.check_output(args).split('\n')
|
||||
if x.strip().startswith('cmds_') and '-' in x]:
|
||||
subcommand, _ = line.split('=')
|
||||
subcommand = subcommand.replace('cmds_', '').replace('_', ' ')
|
||||
subcommands.append(subcommand)
|
||||
else:
|
||||
args.append('bash-completion')
|
||||
subcommands = check_output(args).strip().split()
|
||||
subcommands = subprocess.check_output(args).strip().split()
|
||||
|
||||
subcommands = sorted([o for o in subcommands if not (o.startswith('-') or
|
||||
o in blacklist)])
|
||||
|
|
|
@ -1,41 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
'''
|
||||
Common functions for os_doc_tools.
|
||||
'''
|
||||
|
||||
import subprocess
|
||||
|
||||
|
||||
# NOTE(berendt): check_output as provided in Python 2.7.5 to make script
|
||||
# usable with Python < 2.7
|
||||
def check_output(*popenargs, **kwargs):
|
||||
"""Run command with arguments and return its output as a byte string.
|
||||
|
||||
If the exit code was non-zero it raises a CalledProcessError. The
|
||||
CalledProcessError object will have the return code in the returncode
|
||||
attribute and output in the output attribute.
|
||||
"""
|
||||
if 'stdout' in kwargs:
|
||||
raise ValueError('stdout argument not allowed, it will be overridden.')
|
||||
process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs)
|
||||
output, _ = process.communicate()
|
||||
retcode = process.poll()
|
||||
if retcode:
|
||||
cmd = kwargs.get("args")
|
||||
if cmd is None:
|
||||
cmd = popenargs[0]
|
||||
raise subprocess.CalledProcessError(retcode, cmd, output=output)
|
||||
return output
|
|
@ -50,7 +50,6 @@ from lxml import etree
|
|||
from oslo_config import cfg
|
||||
|
||||
import os_doc_tools
|
||||
from os_doc_tools.common import check_output # noqa
|
||||
from os_doc_tools import jsoncheck
|
||||
from os_doc_tools.openstack.common import log
|
||||
|
||||
|
@ -343,7 +342,7 @@ def www_touched():
|
|||
|
||||
try:
|
||||
git_args = ["git", "diff", "--name-only", "HEAD~1", "HEAD"]
|
||||
modified_files = check_output(git_args).strip().split()
|
||||
modified_files = subprocess.check_output(git_args).strip().split()
|
||||
except (subprocess.CalledProcessError, OSError) as e:
|
||||
print("git failed: %s" % e)
|
||||
sys.exit(1)
|
||||
|
@ -364,7 +363,7 @@ def only_po_touched():
|
|||
|
||||
try:
|
||||
git_args = ["git", "diff", "--name-only", "HEAD~1", "HEAD"]
|
||||
modified_files = check_output(git_args).strip().split()
|
||||
modified_files = subprocess.check_output(git_args).strip().split()
|
||||
except (subprocess.CalledProcessError, OSError) as e:
|
||||
print("git failed: %s" % e)
|
||||
sys.exit(1)
|
||||
|
@ -385,7 +384,7 @@ def only_rst_touched():
|
|||
|
||||
try:
|
||||
git_args = ["git", "diff", "--name-only", "HEAD~1", "HEAD"]
|
||||
modified_files = check_output(git_args).strip().split()
|
||||
modified_files = subprocess.check_output(git_args).strip().split()
|
||||
except (subprocess.CalledProcessError, OSError) as e:
|
||||
print("git failed: %s" % e)
|
||||
sys.exit(1)
|
||||
|
@ -412,7 +411,7 @@ def check_modified_affects_all(rootdir):
|
|||
|
||||
try:
|
||||
git_args = ["git", "diff", "--name-only", "HEAD~1", "HEAD"]
|
||||
modified_files = check_output(git_args).strip().split()
|
||||
modified_files = subprocess.check_output(git_args).strip().split()
|
||||
except (subprocess.CalledProcessError, OSError) as e:
|
||||
print("git failed: %s" % e)
|
||||
sys.exit(1)
|
||||
|
@ -446,7 +445,7 @@ def get_modified_files(rootdir, filtering=None):
|
|||
"HEAD"]
|
||||
if filtering is not None:
|
||||
git_args.append(filtering)
|
||||
modified_files = check_output(git_args).strip().split()
|
||||
modified_files = subprocess.check_output(git_args).strip().split()
|
||||
except (subprocess.CalledProcessError, OSError) as e:
|
||||
print("git failed: %s" % e)
|
||||
sys.exit(1)
|
||||
|
@ -764,7 +763,7 @@ def get_gitroot():
|
|||
|
||||
try:
|
||||
git_args = ["git", "rev-parse", "--show-toplevel"]
|
||||
gitroot = check_output(git_args).rstrip()
|
||||
gitroot = subprocess.check_output(git_args).rstrip()
|
||||
except (subprocess.CalledProcessError, OSError) as e:
|
||||
print("git failed: %s" % e)
|
||||
sys.exit(1)
|
||||
|
@ -777,11 +776,11 @@ def print_gitinfo():
|
|||
|
||||
try:
|
||||
git_cmd = ["git", "rev-parse", "--abbrev-ref", "HEAD"]
|
||||
gitbranch = check_output(git_cmd).rstrip()
|
||||
gitbranch = subprocess.check_output(git_cmd).rstrip()
|
||||
git_cmd = ["git", "show", "--format=%s", "-s"]
|
||||
gitsubject = check_output(git_cmd).rstrip()
|
||||
gitsubject = subprocess.check_output(git_cmd).rstrip()
|
||||
git_cmd = ["git", "show", "--format=%an", "-s"]
|
||||
gitauthor = check_output(git_cmd).rstrip()
|
||||
gitauthor = subprocess.check_output(git_cmd).rstrip()
|
||||
except (subprocess.CalledProcessError, OSError) as e:
|
||||
print("git failed: %s" % e)
|
||||
sys.exit(1)
|
||||
|
|
|
@ -15,7 +15,6 @@ classifier =
|
|||
Programming Language :: Python
|
||||
Programming Language :: Python :: 2
|
||||
Programming Language :: Python :: 2.7
|
||||
Programming Language :: Python :: 2.6
|
||||
|
||||
[files]
|
||||
packages =
|
||||
|
|
Loading…
Reference in New Issue