Skip to content

Commit

Permalink
add pyflakes target & associated fixes. Also decided to save JSON to …
Browse files Browse the repository at this point in the history
…--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.
  • Loading branch information
mpdehaan committed Mar 3, 2012
1 parent 3ad9db4 commit 6541f33
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ pep8:
@echo "#############################################"
pep8 -r --ignore=E501,E221,W291,W391,E302,E251,E203,W293,E231,E303,E201,E225 lib/ bin/

pyflakes:
pyflakes lib/ansible/*.py

clean:
rm -rf build
find . -type f -name "*.pyc" -delete
Expand Down
2 changes: 1 addition & 1 deletion bin/ansible
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Cli(object):
options.one_line
)
if options.tree:
write_tree_file(hostname, msg)
write_tree_file(options.tree, hostname, bigjson(results))
buf += msg

if has_dark_hosts(results):
Expand Down
3 changes: 1 addition & 2 deletions lib/ansible/playbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _run_task(self, pattern=None, task=None, host_list=None,
# load the module name and parameters from the task entry
name = task['name']
action = task['action']
comment = task.get('comment', '')
# comment = task.get('comment', '')

tokens = shlex.split(action)
module_name = tokens[0]
Expand Down Expand Up @@ -167,7 +167,6 @@ def _run_task(self, pattern=None, task=None, host_list=None,

dark = results.get("dark", {})
contacted = results.get("contacted", {})
ok_hosts = contacted.keys()

for host, msg in dark.items():
self.processed[host] = 1
Expand Down
1 change: 0 additions & 1 deletion lib/ansible/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import multiprocessing
import signal
import os
import traceback
import ansible.constants as C
import Queue
import paramiko
Expand Down
7 changes: 4 additions & 3 deletions lib/ansible/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
###############################################################

import sys
import os
try:
import json
except ImportError:
Expand Down Expand Up @@ -94,11 +95,11 @@ def command_failure_msg(hostname, result, oneline):
''' output from a failed command run '''
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 '''
# TODO: might be nice to append playbook runs per host in a similar way
# 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.write(buf)
fd.close()
Expand Down Expand Up @@ -155,7 +156,7 @@ def contacted_host_result(results, hostname):
def prepare_writeable_dir(tree):
''' make sure a directory exists and is writeable '''
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):
try:
os.makedirs(tree)
Expand Down

0 comments on commit 6541f33

Please sign in to comment.