X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lttng_ivc%2Futils%2Futils.py;h=ec8d75b7cae87949fcb4cd4fbb9b4301bc2a396d;hb=bde0c5403b98eb937494cfa22a16aed165213eb0;hp=b2de919301768f1748489b1222d1336ae77d9047;hpb=5676c7e7c4faf843558536f9e9b9b54bdf3faa24;p=deliverable%2Flttng-ivc.git diff --git a/lttng_ivc/utils/utils.py b/lttng_ivc/utils/utils.py index b2de919..ec8d75b 100644 --- a/lttng_ivc/utils/utils.py +++ b/lttng_ivc/utils/utils.py @@ -1,5 +1,7 @@ import signal import hashlib +import os +import time def line_count(file_path): line_count = 0 @@ -17,6 +19,25 @@ def sha256_checksum(filename, block_size=65536): return sha256.hexdigest() +# TODO: timeout as a parameter or Settings +# TODO: Custom exception +def wait_for_file(path): + i = 0 + timeout = 60 + while not os.path.exists(path): + time.sleep(1) + i = i + 1 + if i > timeout: + raise Exception("File still does not exists. Timeout expired") + + +# TODO: find better exception +def create_empty_file(path): + if os.path.exists(path): + raise Exception("Path already exist") + open(path, 'w').close() + + def __dummy_sigusr1_handler(): pass