Did I find the right examples for you? yes no

All Samples(53)  |  Call(38)  |  Derive(0)  |  Import(15)
http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python/377028#377028

        def which(program):
    """
    http://stackoverflow.com/questions/377017/test-if-executable-exists-in-python/377028#377028
    """
    def is_exe(fpath):
        return os.path.exists(fpath) and os.access(fpath, os.X_OK)

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

    return None
        


src/m/o/mongodb-backup-system-HEAD/mbs/strategy.py   mongodb-backup-system(Download)
from subprocess import CalledProcessError
from errors import *
from utils import (which, ensure_dir, execute_command, execute_command_wrapper,
                   listify)
 
            uri += database_name
 
        mongoctl_exe = which("mongoctl")
        if not mongoctl_exe:
            raise MBSError("mongoctl exe not found in PATH")
 
        # read the last dump log line
        last_line_tail_cmd = [which('tail'), '-1', dump_log_path]
        last_dump_line = execute_command(last_line_tail_cmd)
 
    def _execute_tar_command(self, path, filename):
 
        tar_exe = which("tar")
        working_dir = os.path.dirname(path)
        target_dirname = os.path.basename(path)
 
        tarx_cmd = [
            which("tar"),
            "-xf",
            file_reference.file_name

src/t/r/Trail-HEAD/src/printing/PSStream.py   Trail(Download)
def get_systemheader():
    options = settings.get_settings()
    fn = utils.which(
        "header.ps", list(options.user_data_dirs) + [SYSTEM_DATA_DIR])
    if fn:
def get_userheader():
    options = settings.get_settings()
    templates = []
    for fn in settings.get_settings().user_headers:
        filename = utils.which(fn, options.user_data_dirs)

src/c/o/comictagger-1.1.14-beta/comictaggerlib/settings.py   comictagger(Download)
			else:
				# see if it's in the path of unix user
				if utils.which("rar") is not None:
					self.rar_exe_path = utils.which("rar")
			if self.rar_exe_path != "":
			if platform.system() != "Windows":
				# see if it's in the path of unix user
				if utils.which("unrar") is not None:
					self.unrar_exe_path = utils.which("unrar")
			if self.unrar_exe_path != "":

src/m/o/mongodb-backup-system-HEAD/mbs/target.py   mongodb-backup-system(Download)
from mbs import get_mbs
from base import MBSObject
from utils import which, execute_command, export_mbs_object_list
from azure.storage import BlobService
from boto.s3.connection import S3Connection
            chunk_size = MAX_SPLIT_SIZE
 
        st_exe = which("st")
        st_command = [
            st_exe,

src/c/o/comictagger-1.1.14-beta/comictaggerlib/taggerwindow.py   comictagger(Download)
 
		if not folder_mode:
			if platform.system() != "Windows" and utils.which("unrar") is None:
				archive_filter = "Comic archive files (*.cbz *.zip)"
			else:

src/f/i/fingerprint-app-0.2/FingerPrint/blotter.py   fingerprint-app(Download)
                    # the user cmdline could be a symlink so we want to keep track
                    cmd = FingerPrint.syscalltracer.TracerControlBlock.cmdline[binPath][0]
                    cmd = utils.which(cmd)
                    if not cmd :
                        cmd = binPath
        return_paths = []
	ldconf_cmd = "ldconfig"
	if not utils.which(ldconf_cmd) :
            ldconf_cmd = "/sbin/ldconfig"
	if not utils.which(ldconf_cmd) :

src/p/a/pathomx-HEAD/pathomx/resources.py   pathomx(Download)
 
from .custom_exceptions import PathomxExternalResourceUnavailableException, PathomxExternalResourceTimeoutException
from .utils import which
 
 
    def init(self):
        if self.interface == None:
            try:
                self.interface = mlabwrap.init(which(self.exec_path))
            except IOError:
                self.interface._mlab = None  # Complete shutdown
                self.interface = mlabwrap.init(which(self.exec_path))
    def is_available(self):
        if self._is_available == None:
            self._is_available = which(self.exec_path) != None
        return self._is_available
 

src/p/a/Pathomx-2.3.0/pathomx/resources.py   Pathomx(Download)
 
from .custom_exceptions import PathomxExternalResourceUnavailableException, PathomxExternalResourceTimeoutException
from .utils import which
 
class AbstractResource(object):
    def init(self):
        if self.interface == None:
            try:
                self.interface = mlabwrap.init( which(self.exec_path) )
            except IOError:
                self.interface._mlab = None # Complete shutdown            
                self.interface = mlabwrap.init( which(self.exec_path) )
    def is_available(self):
        if self._is_available == None:
            self._is_available = which(self.exec_path) != None
        return self._is_available
 

src/g/e/Gemtools-1.7.1/python/gem/files.py   Gemtools(Download)
import __builtin__
import gem.gemtools as gt
from utils import which
import shutil
import os
        return __zcat_path
 
    __zcat_path = which("gzcat")
    if not __zcat_path:
        __zcat_path = which("zcat")

src/f/i/fingerprint-app-0.2/FingerPrint/sergeant.py   fingerprint-app(Download)
# do we have a prelinker? 
# this variable is use by getHash and by the syscaltracer
prelink = utils.which("prelink")
 
 

  1 | 2  Next