minor code cleanup

pull/596/head
Michael DeHaan 13 years ago
parent c6c07a2526
commit fabded984d

@ -71,14 +71,7 @@ def write_tree_file(tree, hostname, buf):
def is_failed(result): def is_failed(result):
''' is a given JSON result a failed result? ''' ''' is a given JSON result a failed result? '''
failed = False return ((result.get('rc', 0) != 0) or (result.get('failed', False) in [ True, 'True', 'true']))
rc = 0
if type(result) == dict:
failed = result.get('failed', 0)
rc = result.get('rc', 0)
if rc != 0:
return True
return failed
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 '''
@ -200,8 +193,7 @@ def _template(text, vars, setup_cache=None):
''' run a text buffer through the templating engine ''' ''' run a text buffer through the templating engine '''
vars = vars.copy() vars = vars.copy()
vars['hostvars'] = setup_cache vars['hostvars'] = setup_cache
text = varReplace(unicode(text), vars) return varReplace(unicode(text), vars)
return text
def template(text, vars, setup_cache=None): def template(text, vars, setup_cache=None):
''' run a text buffer through the templating engine ''' run a text buffer through the templating engine
@ -265,14 +257,10 @@ def md5(filename):
infile.close() infile.close()
return digest.hexdigest() return digest.hexdigest()
#################################################################### ####################################################################
# option handling code for /usr/bin/ansible and ansible-playbook # option handling code for /usr/bin/ansible and ansible-playbook
# below this line # below this line
# FIXME: move to seperate file
class SortedOptParser(optparse.OptionParser): class SortedOptParser(optparse.OptionParser):
'''Optparser which sorts the options by opt before outputting --help''' '''Optparser which sorts the options by opt before outputting --help'''
def format_help(self, formatter=None): def format_help(self, formatter=None):

Loading…
Cancel
Save