Commit d2605333 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[utils] Move id generator from test utils to utils

parent 63de3e29
......@@ -30,8 +30,6 @@
import os
import shutil
import string
import random
import nose
import docker
......@@ -168,16 +166,6 @@ def cleanup():
#----------------------------------------------------------
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
""" Simple id generator based on
https://stackoverflow.com/a/2257449/5843716
"""
return ''.join(random.choice(chars) for _ in range(size))
#----------------------------------------------------------
def create_network(network_name):
""" Create a docker network with the given name"""
......
......@@ -41,6 +41,8 @@ import sys
import tempfile
import socket
import contextlib
import string
import random
import numpy
import simplejson
......@@ -105,6 +107,9 @@ def find_free_port():
return s.getsockname()[1]
#----------------------------------------------------------
def find_free_port_in_range(min_port, max_port):
'''Returns the value of a free port in range'''
......@@ -117,3 +122,15 @@ def find_free_port_in_range(min_port, max_port):
continue
else:
return sock.getsockname()[1]
#----------------------------------------------------------
def id_generator(size=6, chars=string.ascii_uppercase + string.ascii_lowercase + string.digits):
""" Simple id generator based on
https://stackoverflow.com/a/2257449/5843716
"""
return ''.join(random.choice(chars) for _ in range(size))
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