Fix "import *" and resultant new things detectable from "make pyflakes"
This commit is contained in:
parent
33aa50eae7
commit
c861e0de55
4 changed files with 26 additions and 21 deletions
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
import paramiko
|
import paramiko
|
||||||
import os
|
import os
|
||||||
from ansible.errors import *
|
from ansible import errors
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ class ParamikoConnection(object):
|
||||||
timeout=self.runner.timeout
|
timeout=self.runner.timeout
|
||||||
)
|
)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
raise AnsibleConnectionFailed(str(e))
|
raise errors.AnsibleConnectionFailed(str(e))
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def exec_command(self, cmd):
|
def exec_command(self, cmd):
|
||||||
|
@ -79,12 +79,12 @@ class ParamikoConnection(object):
|
||||||
def put_file(self, in_path, out_path):
|
def put_file(self, in_path, out_path):
|
||||||
''' transfer a file from local to remote '''
|
''' transfer a file from local to remote '''
|
||||||
if not os.path.exists(in_path):
|
if not os.path.exists(in_path):
|
||||||
raise AnsibleFileNotFound("file or module does not exist: %s" % in_path)
|
raise errors.AnsibleFileNotFound("file or module does not exist: %s" % in_path)
|
||||||
sftp = self.ssh.open_sftp()
|
sftp = self.ssh.open_sftp()
|
||||||
try:
|
try:
|
||||||
sftp.put(in_path, out_path)
|
sftp.put(in_path, out_path)
|
||||||
except IOError:
|
except IOError:
|
||||||
raise AnsibleException("failed to transfer file to %s" % out_path)
|
raise errors.AnsibleException("failed to transfer file to %s" % out_path)
|
||||||
sftp.close()
|
sftp.close()
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
|
|
||||||
import ansible.runner
|
import ansible.runner
|
||||||
import ansible.constants as C
|
import ansible.constants as C
|
||||||
from ansible.utils import *
|
from ansible import utils
|
||||||
from ansible.errors import *
|
from ansible import errors
|
||||||
import yaml
|
import yaml
|
||||||
import shlex
|
import shlex
|
||||||
import os
|
import os
|
||||||
|
@ -89,10 +89,10 @@ class PlayBook(object):
|
||||||
def _get_vars(self, play, dirname):
|
def _get_vars(self, play, dirname):
|
||||||
vars = play.get('vars', {})
|
vars = play.get('vars', {})
|
||||||
if type(vars) != dict:
|
if type(vars) != dict:
|
||||||
raise AnsibleError("'vars' section must contain only key/value pairs")
|
raise errors.AnsibleError("'vars' section must contain only key/value pairs")
|
||||||
vars_files = play.get('vars_files', [])
|
vars_files = play.get('vars_files', [])
|
||||||
for f in vars_files:
|
for f in vars_files:
|
||||||
path = path_dwim(dirname, f)
|
path = utils.path_dwim(dirname, f)
|
||||||
# FIXME: better error handling if not valid YAML
|
# FIXME: better error handling if not valid YAML
|
||||||
# or file not found
|
# or file not found
|
||||||
# raise typed exception
|
# raise typed exception
|
||||||
|
@ -105,7 +105,7 @@ class PlayBook(object):
|
||||||
# an include line looks like:
|
# an include line looks like:
|
||||||
# include: some.yml a=2 b=3 c=4
|
# include: some.yml a=2 b=3 c=4
|
||||||
include_tokens = task['include'].split()
|
include_tokens = task['include'].split()
|
||||||
path = path_dwim(dirname, include_tokens[0])
|
path = utils.path_dwim(dirname, include_tokens[0])
|
||||||
inject_vars = self._get_vars(play, dirname)
|
inject_vars = self._get_vars(play, dirname)
|
||||||
for i,x in enumerate(include_tokens):
|
for i,x in enumerate(include_tokens):
|
||||||
if x.find("=") != -1:
|
if x.find("=") != -1:
|
||||||
|
@ -119,7 +119,7 @@ class PlayBook(object):
|
||||||
new_tasks.append(x)
|
new_tasks.append(x)
|
||||||
|
|
||||||
def _include_handlers(self, play, handler, dirname, new_handlers):
|
def _include_handlers(self, play, handler, dirname, new_handlers):
|
||||||
path = path_dwim(dirname, handler['include'])
|
path = utils.path_dwim(dirname, handler['include'])
|
||||||
included = file(path).read()
|
included = file(path).read()
|
||||||
inject_vars = self._get_vars(play, dirname)
|
inject_vars = self._get_vars(play, dirname)
|
||||||
template = jinja2.Template(included)
|
template = jinja2.Template(included)
|
||||||
|
@ -376,7 +376,7 @@ class PlayBook(object):
|
||||||
for host, results in contacted.iteritems():
|
for host, results in contacted.iteritems():
|
||||||
self.processed[host] = 1
|
self.processed[host] = 1
|
||||||
|
|
||||||
if is_failed(results):
|
if utils.is_failed(results):
|
||||||
self.callbacks.on_failed(host, results)
|
self.callbacks.on_failed(host, results)
|
||||||
if not host in self.failures:
|
if not host in self.failures:
|
||||||
self.failures[host] = 1
|
self.failures[host] = 1
|
||||||
|
@ -471,7 +471,7 @@ class PlayBook(object):
|
||||||
for (host, host_result) in contacted_hosts.iteritems():
|
for (host, host_result) in contacted_hosts.iteritems():
|
||||||
if 'failed' in host_result:
|
if 'failed' in host_result:
|
||||||
self.callbacks.on_failed(host, host_result)
|
self.callbacks.on_failed(host, host_result)
|
||||||
self.failed[hosts] = 1
|
self.failed[host] = 1
|
||||||
|
|
||||||
# now for each result, load into the setup cache so we can
|
# now for each result, load into the setup cache so we can
|
||||||
# let runner template out future commands
|
# let runner template out future commands
|
||||||
|
|
|
@ -32,11 +32,16 @@ import tempfile
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from ansible import utils
|
from ansible import utils
|
||||||
from ansible.errors import *
|
from ansible import errors
|
||||||
|
|
||||||
# should be True except in debug
|
# should be True except in debug
|
||||||
CLEANUP_FILES = True
|
CLEANUP_FILES = True
|
||||||
|
|
||||||
|
try:
|
||||||
|
import json
|
||||||
|
except ImportError:
|
||||||
|
import simplejson as json
|
||||||
|
|
||||||
################################################
|
################################################
|
||||||
|
|
||||||
def _executor_hook(job_queue, result_queue):
|
def _executor_hook(job_queue, result_queue):
|
||||||
|
@ -52,7 +57,7 @@ def _executor_hook(job_queue, result_queue):
|
||||||
pass
|
pass
|
||||||
except errors.AnsibleError, ae:
|
except errors.AnsibleError, ae:
|
||||||
result_queue.put([host, False, str(ae)])
|
result_queue.put([host, False, str(ae)])
|
||||||
except Exception, ee:
|
except Exception:
|
||||||
# probably should include the full trace
|
# probably should include the full trace
|
||||||
result_queue.put([host, False, traceback.format_exc()])
|
result_queue.put([host, False, traceback.format_exc()])
|
||||||
|
|
||||||
|
@ -135,7 +140,7 @@ class Runner(object):
|
||||||
host_list = os.path.expanduser(host_list)
|
host_list = os.path.expanduser(host_list)
|
||||||
|
|
||||||
if not os.path.exists(host_list):
|
if not os.path.exists(host_list):
|
||||||
raise AnsibleFileNotFound("inventory file not found: %s" % host_list)
|
raise errors.AnsibleFileNotFound("inventory file not found: %s" % host_list)
|
||||||
|
|
||||||
results = []
|
results = []
|
||||||
groups = { 'ungrouped' : [] }
|
groups = { 'ungrouped' : [] }
|
||||||
|
@ -211,7 +216,7 @@ class Runner(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return [ True, self.connector.connect(host) ]
|
return [ True, self.connector.connect(host) ]
|
||||||
except AnsibleConnectionFailed, e:
|
except errors.AnsibleConnectionFailed, e:
|
||||||
return [ False, "FAILED: %s" % str(e) ]
|
return [ False, "FAILED: %s" % str(e) ]
|
||||||
|
|
||||||
# *****************************************************
|
# *****************************************************
|
||||||
|
@ -557,10 +562,10 @@ class Runner(object):
|
||||||
''' transfer a module over SFTP, does not run it '''
|
''' transfer a module over SFTP, does not run it '''
|
||||||
|
|
||||||
if module.startswith("/"):
|
if module.startswith("/"):
|
||||||
raise AnsibleFileNotFound("%s is not a module" % module)
|
raise errors.AnsibleFileNotFound("%s is not a module" % module)
|
||||||
in_path = os.path.expanduser(os.path.join(self.module_path, module))
|
in_path = os.path.expanduser(os.path.join(self.module_path, module))
|
||||||
if not os.path.exists(in_path):
|
if not os.path.exists(in_path):
|
||||||
raise AnsibleFileNotFound("module not found: %s" % in_path)
|
raise errors.AnsibleFileNotFound("module not found: %s" % in_path)
|
||||||
|
|
||||||
out_path = tmp + module
|
out_path = tmp + module
|
||||||
conn.put_file(in_path, out_path)
|
conn.put_file(in_path, out_path)
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import shlex
|
import shlex
|
||||||
from ansible.errors import *
|
from ansible import errors
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import json
|
import json
|
||||||
|
@ -196,7 +196,7 @@ def parse_json(data):
|
||||||
tokens = shlex.split(data)
|
tokens = shlex.split(data)
|
||||||
for t in tokens:
|
for t in tokens:
|
||||||
if t.find("=") == -1:
|
if t.find("=") == -1:
|
||||||
raise AnsibleError("failed to parse: %s" % data)
|
raise errors.AnsibleError("failed to parse: %s" % data)
|
||||||
(key,value) = t.split("=", 1)
|
(key,value) = t.split("=", 1)
|
||||||
if key == 'changed' or 'failed':
|
if key == 'changed' or 'failed':
|
||||||
if value.lower() in [ 'true', '1' ]:
|
if value.lower() in [ 'true', '1' ]:
|
||||||
|
|
Loading…
Reference in a new issue