1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

python3 compatiblity

remove use of basestring
deal with configparser
This commit is contained in:
Brian Coca 2016-03-16 14:12:48 -07:00
parent 943e4d37f5
commit 5b11494437
5 changed files with 13 additions and 7 deletions

View file

@ -168,8 +168,9 @@ class PlaybookExecutor:
# send the stats callback for this playbook # send the stats callback for this playbook
if self._tqm is not None: if self._tqm is not None:
if C.RETRY_FILES_ENABLED: if C.RETRY_FILES_ENABLED:
retries = list(set(self._tqm._failed_hosts.keys() + self._tqm._unreachable_hosts.keys())) retries = set(self._tqm._failed_hosts.keys())
retries.sort() retries.update(self._tqm._unreachable_hosts.keys())
retries = sorted(retries)
if len(retries) > 0: if len(retries) > 0:
if C.RETRY_FILES_SAVE_PATH: if C.RETRY_FILES_SAVE_PATH:
basedir = C.shell_expand(C.RETRY_FILES_SAVE_PATH) basedir = C.shell_expand(C.RETRY_FILES_SAVE_PATH)

View file

@ -607,7 +607,8 @@ class TaskExecutor:
try: try:
cmd = subprocess.Popen(['ssh','-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) cmd = subprocess.Popen(['ssh','-o','ControlPersist'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(out, err) = cmd.communicate() (out, err) = cmd.communicate()
if "Bad configuration option" in err or "Usage:" in err: err = to_unicode(err)
if u"Bad configuration option" in err or u"Usage:" in err:
conn_type = "paramiko" conn_type = "paramiko"
except OSError: except OSError:
conn_type = "paramiko" conn_type = "paramiko"
@ -645,7 +646,9 @@ class TaskExecutor:
try: try:
connection._connect() connection._connect()
except AnsibleConnectionFailure: except AnsibleConnectionFailure:
display.debug('connection failed, fallback to accelerate')
res = handler._execute_module(module_name='accelerate', module_args=accelerate_args, task_vars=variables, delete_remote_tmp=False) res = handler._execute_module(module_name='accelerate', module_args=accelerate_args, task_vars=variables, delete_remote_tmp=False)
display.debug(res)
connection._connect() connection._connect()
return connection return connection

View file

@ -34,6 +34,7 @@ from ansible.template import Templar
from ansible.vars.hostvars import HostVars from ansible.vars.hostvars import HostVars
from ansible.plugins.callback import CallbackBase from ansible.plugins.callback import CallbackBase
from ansible.utils.unicode import to_unicode from ansible.utils.unicode import to_unicode
from ansible.compat.six import string_types
try: try:
from __main__ import display from __main__ import display
@ -143,7 +144,7 @@ class TaskQueueManager:
if isinstance(self._stdout_callback, CallbackBase): if isinstance(self._stdout_callback, CallbackBase):
stdout_callback_loaded = True stdout_callback_loaded = True
elif isinstance(self._stdout_callback, basestring): elif isinstance(self._stdout_callback, string_types):
if self._stdout_callback not in callback_loader: if self._stdout_callback not in callback_loader:
raise AnsibleError("Invalid callback for stdout specified: %s" % self._stdout_callback) raise AnsibleError("Invalid callback for stdout specified: %s" % self._stdout_callback)
else: else:

View file

@ -60,8 +60,9 @@ import socket
import random import random
import time import time
import codecs import codecs
import ConfigParser
import uuid import uuid
from ansible.compat.six.moves import configparser
try: try:
import certifi import certifi
HAS_CERTIFI = True HAS_CERTIFI = True
@ -212,7 +213,7 @@ class CallbackModule(CallbackBase):
'Disabling the Logentries callback plugin.') 'Disabling the Logentries callback plugin.')
config_path = os.path.abspath(os.path.dirname(__file__)) config_path = os.path.abspath(os.path.dirname(__file__))
config = ConfigParser.ConfigParser() config = configparser.ConfigParser()
try: try:
config.readfp(open(os.path.join(config_path, 'logentries.ini'))) config.readfp(open(os.path.join(config_path, 'logentries.ini')))
if config.has_option('logentries', 'api'): if config.has_option('logentries', 'api'):

View file

@ -79,7 +79,7 @@ class Connection(ConnectionBase):
p = subprocess.Popen( p = subprocess.Popen(
cmd, cmd,
shell=isinstance(cmd, basestring), shell=isinstance(cmd, (text_type, binary_type)),
executable=executable, #cwd=... executable=executable, #cwd=...
stdin=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,