Commit 6efc8008 by Henry Finucane

Fail fast in the presence of permissions issues

parent 278ecb9b
...@@ -176,7 +176,8 @@ def main(): ...@@ -176,7 +176,8 @@ def main():
end = start + datetime.timedelta(seconds=timeout) end = start + datetime.timedelta(seconds=timeout)
while datetime.datetime.now() < end: while datetime.datetime.now() < end:
if path: if path:
if os.path.exists(path): try:
os.stat(path)
if search_regex: if search_regex:
try: try:
f = open(path) f = open(path)
...@@ -192,8 +193,13 @@ def main(): ...@@ -192,8 +193,13 @@ def main():
pass pass
else: else:
break break
else: except OSError, e:
time.sleep(1) # File not present
if os.errno == 2:
time.sleep(1)
else:
elapsed = datetime.datetime.now() - start
module.fail_json(msg="Failed to stat %s, %s" % (path, e.strerror), elapsed=elapsed.seconds)
elif port: elif port:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(connect_timeout) s.settimeout(connect_timeout)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment