forked from eucalyptus/nephoria
-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
38 lines (28 loc) · 1.09 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
import testcase_utils
import re
import random
import string
__version__ = '2.2'
__DEFAULT_API_VERSION__ = '2015-10-01'
def handle_timeout(self, signum, frame):
raise testcase_utils.TimeoutFunctionException()
def grep(self, string, list):
""" Remove the strings from the list that do not match the regex string"""
expr = re.compile(string)
return filter(expr.search,list)
def render_file_template(src, dest, **kwargs):
from cloud_utils import file_utils
return file_utils.render_file_template(src, dest, **kwargs)
def id_generator(size=6, chars=None):
"""Returns a string of size with random charachters from the chars array.
size Size of string to return
chars Array of characters to use in generation of the string
"""
chars = chars or (string.ascii_uppercase + string.ascii_lowercase + string.digits)
return ''.join(random.choice(chars) for x in range(size))
class CleanTestResourcesException(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)