def has_binary(command): try: local.which(command) return True except CommandNotFound: log.info('%s does not exist' % command) return False
def test_local(self): self.assertTrue("plumbum" in str(local.cwd)) self.assertTrue("PATH" in local.env.getdict()) self.assertEqual(local.path("foo"), os.path.join(os.getcwd(), "foo")) local.which("ls") local["ls"] self.assertEqual(local.python("-c", "print ('hi there')").splitlines(), ["hi there"])
def test_local(self): from plumbum.cmd import cat, head assert "plumbum" in str(local.cwd) assert "PATH" in local.env.getdict() assert local.path("foo") == os.path.join(os.getcwd(), "foo") local.which("ls") local["ls"] assert local.python("-c", "print ('hi there')").splitlines() == ["hi there"]
def test_env(self): assert "PATH" in local.env assert "FOOBAR72" not in local.env with pytest.raises(ProcessExecutionError): local.python("-c", "import os;os.environ['FOOBAR72']") local.env["FOOBAR72"] = "spAm" assert local.python("-c", "import os;print (os.environ['FOOBAR72'])").splitlines() == ["spAm"] with local.env(FOOBAR73 = 1889): assert local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines() == ["1889"] with local.env(FOOBAR73 = 1778): assert local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines() == ["1778"] assert local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines() == ["1889"] with pytest.raises(ProcessExecutionError): local.python("-c", "import os;os.environ['FOOBAR73']") # path manipulation with pytest.raises(CommandNotFound): local.which("dummy-executable") with local.env(): local.env.path.insert(0, local.cwd / "not-in-path") p = local.which("dummy-executable") assert p == local.cwd / "not-in-path" / "dummy-executable"
def test_env(self): self.assertTrue("PATH" in local.env) self.assertFalse("FOOBAR72" in local.env) self.assertRaises(ProcessExecutionError, local.python, "-c", "import os;os.environ['FOOBAR72']") local.env["FOOBAR72"] = "spAm" self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR72'])").splitlines(), ["spAm"]) with local.env(FOOBAR73 = 1889): self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines(), ["1889"]) with local.env(FOOBAR73 = 1778): self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines(), ["1778"]) self.assertEqual(local.python("-c", "import os;print (os.environ['FOOBAR73'])").splitlines(), ["1889"]) self.assertRaises(ProcessExecutionError, local.python, "-c", "import os;os.environ['FOOBAR73']") # path manipulation self.assertRaises(CommandNotFound, local.which, "dummy-executable") with local.env(): local.env.path.insert(0, local.cwd / "not-in-path") p = local.which("dummy-executable") self.assertEqual(p, local.cwd / "not-in-path" / "dummy-executable")
def can_build_udfs(): try: local.which('cmake') except CommandNotFound: logger.exception('Could not find cmake on PATH') return False try: local.which('make') except CommandNotFound: logger.exception('Could not find make on PATH') return False try: local.which('clang++') except CommandNotFound: logger.exception( 'Could not find LLVM on PATH; if IBIS_TEST_LLVM_CONFIG is set, ' 'try setting PATH="$($IBIS_TEST_LLVM_CONFIG --bindir):$PATH"') return False return True
def can_build_udfs(): try: local.which('cmake') except CommandNotFound: logger.exception('Could not find cmake on PATH') return False try: local.which('make') except CommandNotFound: logger.exception('Could not find make on PATH') return False try: local.which('clang++') except CommandNotFound: logger.exception( 'Could not find LLVM on PATH; if IBIS_TEST_LLVM_CONFIG is set, ' 'try setting PATH="$($IBIS_TEST_LLVM_CONFIG --bindir):$PATH"' ) return False return True
def install_zsh(): install_with_apt("zsh") cmd.sudo[cmd.chsh["-s", local.which("zsh"), os.environ["USER"]]]()
from plumbum import local from plumbum.cmd import grep, wc, cat, head print local.env.user print local.env.home print local.env.path print local.which("python")