summaryrefslogtreecommitdiff
path: root/yarns/lib.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2017-04-01 17:29:47 +0300
committerLars Wirzenius <liw@liw.fi>2017-04-01 19:24:49 +0300
commit2749e79c17325bc6ee475f324cf077e9c312fcca (patch)
tree265e53d101fe6c8ac11dca6619aafa77b40f70a7 /yarns/lib.py
parent2d6a1ead51d7229b2a14d056d02cae9a8c8f642b (diff)
downloadick2-2749e79c17325bc6ee475f324cf077e9c312fcca.tar.gz
Add skeleton for a smoke test yarn
Diffstat (limited to 'yarns/lib.py')
-rw-r--r--yarns/lib.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/yarns/lib.py b/yarns/lib.py
new file mode 100644
index 0000000..b7df3a7
--- /dev/null
+++ b/yarns/lib.py
@@ -0,0 +1,29 @@
+import errno
+import os
+import time
+
+import cliapp
+
+import yarnutils
+
+datadir = os.environ['DATADIR']
+srcdir = os.environ['SRCDIR']
+
+vars = yarnutils.Variables(datadir)
+
+
+MAX_CAT_TIME = 5 # seconds
+def cat(filename):
+ start = time.time()
+ while time.time() - start < MAX_CAT_TIME:
+ try:
+ with open(filename) as f:
+ data = f.read()
+ if len(data) == 0:
+ continue
+ return data
+ except (IOError, OSError) as e:
+ if e.errno == errno.ENOENT:
+ continue
+ raise
+ raise Exception("cat took more then %s seconds" % MAX_CAT_TIME)