def get_lxd_version(): if not Executables.has('lxd'): return '0.0.0' cmd = [Executables.get('lxd'), '--version'] result = run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if not result.stdout: # recent lxd versions print the version to stderr! return result.stderr.strip('\n') else: return result.stdout.strip('\n')
def test_executables(): executables = Executables(clear_cache=True) assert executables.has('ls') is True assert executables.get('true') == '/bin/true' or executables.get('true') == '/usr/bin/true' assert executables.has('does-really-not-exist') is False assert executables.get('does-not-exist-at-all') is None assert executables.has('ls') is True # cache assert executables.has('does-really-not-exist') is False
def lxc_exec(): return Executables.get('lxc')