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

add pyflakes target & associated fixes. Also decided to save JSON to --tree file so it can

be better used programatically.  May have to come up with another system of tree logging for
playbook if playbook decides to have tree logging.  Presumably not the highest priority.
This commit is contained in:
Michael DeHaan 2012-03-02 22:10:51 -05:00
parent 3ad9db4966
commit 6541f338df
5 changed files with 9 additions and 7 deletions

View file

@ -26,6 +26,9 @@ pep8:
@echo "#############################################" @echo "#############################################"
pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225 lib/ bin/ pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225 lib/ bin/
pyflakes:
pyflakes lib/ansible/*.py
clean: clean:
rm -rf build rm -rf build
find . -type f -name "*.pyc" -delete find . -type f -name "*.pyc" -delete

View file

@ -119,7 +119,7 @@ class Cli(object):
options.one_line options.one_line
) )
if options.tree: if options.tree:
write_tree_file(hostname, msg) write_tree_file(options.tree, hostname, bigjson(results))
buf += msg buf += msg
if has_dark_hosts(results): if has_dark_hosts(results):

View file

@ -137,7 +137,7 @@ class PlayBook(object):
# load the module name and parameters from the task entry # load the module name and parameters from the task entry
name = task['name'] name = task['name']
action = task['action'] action = task['action']
comment = task.get('comment', '') # comment = task.get('comment', '')
tokens = shlex.split(action) tokens = shlex.split(action)
module_name = tokens[0] module_name = tokens[0]
@ -167,7 +167,6 @@ class PlayBook(object):
dark = results.get("dark", {}) dark = results.get("dark", {})
contacted = results.get("contacted", {}) contacted = results.get("contacted", {})
ok_hosts = contacted.keys()
for host, msg in dark.items(): for host, msg in dark.items():
self.processed[host] = 1 self.processed[host] = 1

View file

@ -27,7 +27,6 @@ import fnmatch
import multiprocessing import multiprocessing
import signal import signal
import os import os
import traceback
import ansible.constants as C import ansible.constants as C
import Queue import Queue
import paramiko import paramiko

View file

@ -18,6 +18,7 @@
############################################################### ###############################################################
import sys import sys
import os
try: try:
import json import json
except ImportError: except ImportError:
@ -94,11 +95,11 @@ def command_failure_msg(hostname, result, oneline):
''' output from a failed command run ''' ''' output from a failed command run '''
return command_generic_msg(hostname, result, oneline, 'FAILED') return command_generic_msg(hostname, result, oneline, 'FAILED')
def write_tree_file(hostname,buf): def write_tree_file(tree, hostname, buf):
''' write something into treedir/hostname ''' ''' write something into treedir/hostname '''
# TODO: might be nice to append playbook runs per host in a similar way # TODO: might be nice to append playbook runs per host in a similar way
# in which case, we'd want append mode. # in which case, we'd want append mode.
path = os.path.join(options.tree, hostname) path = os.path.join(tree, hostname)
fd = open(path, "w+") fd = open(path, "w+")
fd.write(buf) fd.write(buf)
fd.close() fd.close()
@ -155,7 +156,7 @@ def contacted_host_result(results, hostname):
def prepare_writeable_dir(tree): def prepare_writeable_dir(tree):
''' make sure a directory exists and is writeable ''' ''' make sure a directory exists and is writeable '''
if tree != '/': if tree != '/':
tree = os.path.realpath(os.path.expanduser(options.tree)) tree = os.path.realpath(os.path.expanduser(tree))
if not os.path.exists(tree): if not os.path.exists(tree):
try: try:
os.makedirs(tree) os.makedirs(tree)