diff options
author | Henry Finucane <henry.finucane@locationlabs.com> | 2014-05-12 23:21:55 -0700 |
---|---|---|
committer | Henry Finucane <henry.finucane@locationlabs.com> | 2014-05-12 23:21:55 -0700 |
commit | 278ecb9b55f8918610038f649f8b6fe4b123d664 (patch) | |
tree | 2f0d7ea74c5bf9d1791caeedc908a124a92fcdee /library | |
parent | 41169666b09a1a9031ef32a9cd72dfefcab31dd3 (diff) | |
download | ansible-278ecb9b55f8918610038f649f8b6fe4b123d664.tar.gz |
Allow wait_for to wait on non-traditional files
Use os.path.exists to check for file existence, instead of "can we open
this file for reading".
Fixes #6710
Diffstat (limited to 'library')
-rw-r--r-- | library/utilities/wait_for | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/library/utilities/wait_for b/library/utilities/wait_for index 3a381f0694..2a43ecf16a 100644 --- a/library/utilities/wait_for +++ b/library/utilities/wait_for @@ -176,21 +176,24 @@ def main(): end = start + datetime.timedelta(seconds=timeout) while datetime.datetime.now() < end: if path: - try: - f = open(path) - try: - if search_regex: - if re.search(search_regex, f.read(), re.MULTILINE): - break - else: - time.sleep(1) - else: - break - finally: - f.close() - except IOError: + if os.path.exists(path): + if search_regex: + try: + f = open(path) + try: + if re.search(search_regex, f.read(), re.MULTILINE): + break + else: + time.sleep(1) + finally: + f.close() + except IOError: + time.sleep(1) + pass + else: + break + else: time.sleep(1) - pass elif port: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(connect_timeout) |