Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(11)  |  Call(9)  |  Derive(0)  |  Import(2)
Similar to Linux/Unix `which`: return (first) path of executable

:param program: program name to search for in PATH
:return: Return the PATH of `program` or None

        def which(program):
    """Similar to Linux/Unix `which`: return (first) path of executable

    :param program: program name to search for in PATH
    :return: Return the PATH of `program` or None
    """
    def is_exe(fpath):
        """Determine if argument exists and is executable"""
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)

    fpath = os.path.split(program)
    if fpath[0]:
        if is_exe(program):
            return program
    else:
        for path in os.environ["PATH"].split(os.pathsep):
            path = path.strip('"')
            exe_file = os.path.join(path, program)
            if is_exe(exe_file):
                return exe_file
    return None
        


src/x/n/Xnt-0.6.3/xnt/vcs/hg.py   Xnt(Download)
    :param branch: Branch to clone
    """
    assert xnt.tasks.which("hg")
    command = ["hg", "clone"]
    if rev:
    :param source: Repository's upstream source
    """
    assert xnt.tasks.which("hg")
    command = ["hg", "pull", "-u", source]
    cwd = os.getcwd()

src/x/n/Xnt-0.6.3/xnt/vcs/git.py   Xnt(Download)
    :param branch: Branch to clone
    """
    assert xnt.tasks.which("git")
    command = ["git", "clone"]
    command = xnt.vcs.clone_options(command, url, branch, dest)
    :param branch: Repository's upstream branch to pull from
    """
    assert xnt.tasks.which("git")
    cwd = os.getcwd()
    os.chdir(path)

src/x/n/Xnt-0.6.3/xnt/vcs/cvs.py   Xnt(Download)
import os
import subprocess
from xnt.tasks import which
 
def cvsco(module, rev="", dest=""):
    :param dest: Destination directory or name of checked out module
    """
    assert which("cvs")
    cmd = ["cvs", "co", "-P"]
    if rev:
    :param path: Directory path to module to update
    """
    assert which("cvs")
    cwd = os.path.abspath(os.getcwd())
    os.chdir(path)

src/x/n/Xnt-0.6.3/xnt/__init__.py   Xnt(Download)
from xnt.tasks import call
from xnt.tasks import setup
from xnt.tasks import which
from xnt.tasks import in_path
 

src/x/n/Xnt-0.6.3/xnt/tests/taskmisctests.py   Xnt(Download)
    def test_which_finds_python(self):
        """Test which can find python"""
        if os.name == 'posix':
            path = xnt.tasks.which("python")
        else:
            path = xnt.tasks.which("python.exe")
    def test_which_dne(self):
        """Test which cannot find not existent program"""
        path = xnt.tasks.which("arst")
        self.assertIsNone(path)