aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/utils/ceedutil.py
blob: ea75b90ff77a7f59011d897b134ca5cc6b21fee3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# some shared utility functions
import subprocess

ToolchainNameBase="crops-toolchain-test"
ToolchainNumber=4
CodiPort=10000
def cmd_exists(cmd):
    return subprocess.call ("command -v "+cmd,shell=True,
                            stdout=subprocess.PIPE,stderr=subprocess.PIPE)==0

def getDockerMachineAddress():
    machine_name=subprocess.check_output(['docker-machine','active'])
    ADDRESS=subprocess.check_output(['docker-machine','ip',machine_name.strip()])
    return ADDRESS

def getDockerAddress():
    ADDRESS="127.0.0.1"
    if cmd_exists('docker-machine'):
        ADDRESS=getDockerMachineAddress()
    return ADDRESS