Merge pull request #1186 from cclauss/execfile-file-reduce-StandardError

Miscellaneous Python 3 changes: execfile(), file(), reduce(), StandardError
This commit is contained in:
Chris Church
2018-02-13 15:11:24 -05:00
committed by GitHub
6 changed files with 8 additions and 4 deletions

View File

@@ -25,4 +25,5 @@ import ansible
# Because of the way Ansible loads plugins, it's not possible to import # Because of the way Ansible loads plugins, it's not possible to import
# ansible.plugins.callback.minimal when being loaded as the minimal plugin. Ugh. # ansible.plugins.callback.minimal when being loaded as the minimal plugin. Ugh.
execfile(os.path.join(os.path.dirname(ansible.__file__), 'plugins', 'callback', 'minimal.py')) with open(os.path.join(os.path.dirname(ansible.__file__), 'plugins', 'callback', 'minimal.py')) as in_file:
exec(in_file.read())

View File

@@ -44,7 +44,7 @@ def could_be_playbook(project_path, dir_path, filename):
# show up. # show up.
matched = False matched = False
try: try:
for n, line in enumerate(file(playbook_path)): for n, line in enumerate(open(playbook_path)):
if valid_playbook_re.match(line): if valid_playbook_re.match(line):
matched = True matched = True
# Any YAML file can also be encrypted with vault; # Any YAML file can also be encrypted with vault;

View File

@@ -18,6 +18,7 @@ import contextlib
import tempfile import tempfile
import six import six
import psutil import psutil
from functools import reduce
from StringIO import StringIO from StringIO import StringIO
from decimal import Decimal from decimal import Decimal

View File

@@ -1,4 +1,5 @@
import re import re
from functools import reduce
from pyparsing import ( from pyparsing import (
infixNotation, infixNotation,
opAssoc, opAssoc,

View File

@@ -322,4 +322,5 @@ if __name__ == '__main__':
imp.load_source('ansible.cli.inventory', __file__ + '.py', f) imp.load_source('ansible.cli.inventory', __file__ + '.py', f)
ansible_path = distutils.spawn.find_executable('ansible') ansible_path = distutils.spawn.find_executable('ansible')
sys.argv[0] = 'ansible-inventory' sys.argv[0] = 'ansible-inventory'
execfile(ansible_path) with open(ansible_path) as in_file:
exec(in_file.read())

View File

@@ -31,7 +31,7 @@ def has_bom(fn):
return sample.startswith((codecs.BOM_UTF8, codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE)) return sample.startswith((codecs.BOM_UTF8, codecs.BOM_UTF16_LE, codecs.BOM_UTF16_BE))
def popen_wrapper(args, os_err_exc_type=StandardError, stdout_encoding='utf-8'): def popen_wrapper(args, os_err_exc_type=Exception, stdout_encoding='utf-8'):
""" """
Friendly wrapper around Popen. Friendly wrapper around Popen.
Returns stdout output, stderr output and OS status code. Returns stdout output, stderr output and OS status code.