Test for directory existance, fix exception catching granularity

This commit is contained in:
Michael DeHaan 2012-10-11 07:56:01 -04:00
parent 448c89a06d
commit f3d7294690
2 changed files with 10 additions and 6 deletions

View file

@ -41,9 +41,13 @@ class Task(object):
def __init__(self, play, ds, module_vars=None): def __init__(self, play, ds, module_vars=None):
''' constructor loads from a task or handler datastructure ''' ''' constructor loads from a task or handler datastructure '''
# code to allow for saying "modulename: args" versus "action: modulename args"
modules_list = set() modules_list = set()
for path in C.DEFAULT_MODULE_PATH.split(pathsep): for path in C.DEFAULT_MODULE_PATH.split(pathsep):
modules_list.update(os.listdir(path)) if os.path.exists(path):
modules_list.update(os.listdir(path))
modules_list = list(modules_list) modules_list = list(modules_list)
for x in ds.keys(): for x in ds.keys():
if x in modules_list: if x in modules_list:
@ -77,10 +81,10 @@ class Task(object):
# delegate_to can use variables # delegate_to can use variables
if not (self.delegate_to is None): if not (self.delegate_to is None):
self.delegate_to = utils.template(None, self.delegate_to, self.module_vars) self.delegate_to = utils.template(None, self.delegate_to, self.module_vars)
# delegate_to: localhost should use local transport # delegate_to: localhost should use local transport
if self.delegate_to in ['127.0.0.1', 'localhost']: if self.delegate_to in ['127.0.0.1', 'localhost']:
self.transport = 'local' self.transport = 'local'
# notified by is used by Playbook code to flag which hosts # notified by is used by Playbook code to flag which hosts
# need to run a notifier # need to run a notifier

View file

@ -467,7 +467,7 @@ class Runner(object):
data2 = utils.last_non_blank_line(data) data2 = utils.last_non_blank_line(data)
try: try:
return data2.split()[0] return data2.split()[0]
except: except IndexError:
sys.stderr.write("warning: md5sum command failed unusually, please report this to the list so it can be fixed\n") sys.stderr.write("warning: md5sum command failed unusually, please report this to the list so it can be fixed\n")
sys.stderr.write("command: %s\n" % md5s) sys.stderr.write("command: %s\n" % md5s)
sys.stderr.write("----\n") sys.stderr.write("----\n")