当前位置: 首页>>代码示例>>Python>>正文


Python spawn.find_executable方法代码示例

本文整理汇总了Python中distutils.spawn.find_executable方法的典型用法代码示例。如果您正苦于以下问题:Python spawn.find_executable方法的具体用法?Python spawn.find_executable怎么用?Python spawn.find_executable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在distutils.spawn的用法示例。


在下文中一共展示了spawn.find_executable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: find_gae_path

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def find_gae_path():
  global GAE_PATH
  if GAE_PATH:
    return GAE_PATH
  if IS_WINDOWS:
    gae_path = None
    for path in os.environ['PATH'].split(os.pathsep):
      if os.path.isfile(os.path.join(path, 'dev_appserver.py')):
        gae_path = path
  else:
    gae_path = spawn.find_executable('dev_appserver.py')
    if gae_path:
      gae_path = os.path.dirname(os.path.realpath(gae_path))
  if not gae_path:
    return ''
  gcloud_exec = 'gcloud.cmd' if IS_WINDOWS else 'gcloud'
  if not os.path.isfile(os.path.join(gae_path, gcloud_exec)):
    GAE_PATH = gae_path
  else:
    gae_path = os.path.join(gae_path, '..', 'platform', 'google_appengine')
    if os.path.exists(gae_path):
      GAE_PATH = os.path.realpath(gae_path)
  return GAE_PATH 
开发者ID:lipis,项目名称:github-stats,代码行数:25,代码来源:run.py

示例2: try_to_find_osquery

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def try_to_find_osquery(self):
        extention = ""
        if platform.system() == "Windows":
            extention = ".exe"

        try:
            return resources.get_resource("osqueryi" + extention)
        except IOError as e:
            # Maybe it is installed on the system.
            if  platform.system() == "Windows":
                result = r"c:\ProgramData\osquery\osqueryi.exe"
                if os.access(result, os.R_OK):
                    return result

            else:
                # Try to find it somewhere on the system.
                return spawn.find_executable("osqueryi")

            raise e 
开发者ID:google,项目名称:rekall,代码行数:21,代码来源:osquery.py

示例3: tearDown

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def tearDown(self):
        dist_coverage_path = os.path.join(MARS_ROOT, '.dist-coverage')
        if os.path.exists(dist_coverage_path):
            # change ownership of coverage files
            if find_executable('sudo'):
                proc = subprocess.Popen(['sudo', '-n', 'chown', '-R', '%d:%d' % (os.geteuid(), os.getegid()),
                                         dist_coverage_path], shell=False)
                proc.wait()

            # rewrite paths in coverage result files
            for fn in glob.glob(os.path.join(dist_coverage_path, '.coverage.*')):
                if 'COVERAGE_FILE' in os.environ:
                    new_cov_file = os.environ['COVERAGE_FILE'] \
                                   + os.path.basename(fn).replace('.coverage', '')
                else:
                    new_cov_file = fn.replace('.dist-coverage' + os.sep, '')
                shutil.copyfile(fn, new_cov_file)
            shutil.rmtree(dist_coverage_path) 
开发者ID:mars-project,项目名称:mars,代码行数:20,代码来源:test_kubernetes.py

示例4: tearDown

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def tearDown(self):
        time.sleep(5)
        dist_coverage_path = os.path.join(MARS_ROOT, '.dist-coverage')
        if os.path.exists(dist_coverage_path):
            # change ownership of coverage files
            if find_executable('sudo'):
                proc = subprocess.Popen(['sudo', '-n', 'chown', '-R', '%d:%d' % (os.geteuid(), os.getegid()),
                                         dist_coverage_path], shell=False)
                proc.wait()

            # rewrite paths in coverage result files
            for fn in glob.glob(os.path.join(dist_coverage_path, '.coverage.*')):
                cov_db = sqlite3.connect(fn)
                c = cov_db.cursor()
                c.execute('UPDATE file SET path=REPLACE(path, \'%s\', \'\')' % (MARS_ROOT + os.path.sep))
                cov_db.commit()
                cov_db.close()

                if 'COVERAGE_FILE' in os.environ:
                    new_cov_file = os.environ['COVERAGE_FILE'] \
                                   + os.path.basename(fn).replace('.coverage', '')
                else:
                    new_cov_file = fn.replace('.dist-coverage' + os.sep, '')
                shutil.copyfile(fn, new_cov_file)
            shutil.rmtree(dist_coverage_path) 
开发者ID:mars-project,项目名称:mars,代码行数:27,代码来源:test_yarn.py

示例5: setbgcolor

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def setbgcolor(line, color):
    # hack hack hack
    # add a bgcolor attribute to all escape sequences found
    import re
    setbg = '\x1b[%sm' % color
    regexbg = '\\1;%sm' % color
    result = setbg + re.sub('(\x1b\\[.*?)m', regexbg, line) + '\x1b[00m'
    if os.environ.get('TERM') == 'eterm-color':
        # it seems that emacs' terminal has problems with some ANSI escape
        # sequences. Eg, 'ESC[44m' sets the background color in all terminals
        # I tried, but not in emacs. To set the background color, it needs to
        # have also an explicit foreground color, e.g. 'ESC[37;44m'. These
        # three lines are a hack, they try to add a foreground color to all
        # escape sequences which are not recognized by emacs. However, we need
        # to pick one specific fg color: I choose white (==37), but you might
        # want to change it.  These lines seems to work fine with the ANSI
        # codes produced by pygments, but they are surely not a general
        # solution.
        result = result.replace(setbg, '\x1b[37;%dm' % color)
        result = result.replace('\x1b[00;%dm' % color, '\x1b[37;%dm' % color)
        result = result.replace('\x1b[39;49;00;', '\x1b[37;')
    return result 
开发者ID:pdbpp,项目名称:pdbpp,代码行数:24,代码来源:pdbpp.py

示例6: _disable_pytest_capture_maybe

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def _disable_pytest_capture_maybe(self):
        try:
            import py.test
            # Force raising of ImportError if pytest is not installed.
            py.test.config
        except (ImportError, AttributeError):
            return
        try:
            capman = py.test.config.pluginmanager.getplugin('capturemanager')
            capman.suspendcapture()
        except KeyError:
            pass
        except AttributeError:
            # Newer pytest with support ready, or very old py.test for which
            # this hack does not work.
            pass 
开发者ID:pdbpp,项目名称:pdbpp,代码行数:18,代码来源:pdbpp.py

示例7: _install_linecache_wrapper

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def _install_linecache_wrapper(self):
        """Disable linecache.checkcache to not invalidate caches.

        This gets installed permanently to also bypass e.g. pytest using
        `inspect.getsource`, which would invalidate it outside of the
        interaction them.
        """
        if not hasattr(self, "_orig_linecache_checkcache"):
            import linecache

            # Save it, although not used really (can be useful for debugging).
            self._orig_linecache_checkcache = linecache.checkcache

            def _linecache_checkcache(*args, **kwargs):
                return

            linecache.checkcache = _linecache_checkcache 
开发者ID:pdbpp,项目名称:pdbpp,代码行数:19,代码来源:pdbpp.py

示例8: do_track

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def do_track(self, arg):
        """
        track expression

        Display a graph showing which objects are referred by the
        value of the expression.  This command requires pypy to be in
        the current PYTHONPATH.
        """
        try:
            from rpython.translator.tool.reftracker import track
        except ImportError:
            print('** cannot import pypy.translator.tool.reftracker **',
                  file=self.stdout)
            return
        try:
            val = self._getval(arg)
        except:
            pass
        else:
            track(val) 
开发者ID:pdbpp,项目名称:pdbpp,代码行数:22,代码来源:pdbpp.py

示例9: _get_editor_cmd

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def _get_editor_cmd(self, filename, lineno):
        editor = self.config.editor
        if editor is None:
            try:
                editor = os.environ["EDITOR"]
            except KeyError:
                try:
                    from shutil import which
                except ImportError:
                    from distutils.spawn import find_executable as which
                editor = which("vim")
                if editor is None:
                    editor = which("vi")
            if not editor:
                raise RuntimeError("Could not detect editor. Configure it or set $EDITOR.")  # noqa: E501
        return self._format_editcmd(editor, filename, lineno) 
开发者ID:pdbpp,项目名称:pdbpp,代码行数:18,代码来源:pdbpp.py

示例10: set_trace

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def set_trace(self, frame=None):
        """Remember starting frame.

        This is used with pytest, which does not use pdb.set_trace().
        """
        if getattr(local, "_pdbpp_completing", False):
            # Handle set_trace being called during completion, e.g. with
            # fancycompleter's attr_matches.
            return
        if self.disabled:
            return

        if frame is None:
            frame = sys._getframe().f_back
        self._via_set_trace_frame = frame
        self._stopped_for_set_trace = False

        self.start_filename = frame.f_code.co_filename
        self.start_lineno = frame.f_lineno

        return super(Pdb, self).set_trace(frame) 
开发者ID:pdbpp,项目名称:pdbpp,代码行数:23,代码来源:pdbpp.py

示例11: find_sdk_path

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def find_sdk_path():
  """Find the App Engine SDK path."""
  if common.get_platform() == 'windows':
    _, gcloud_path = common.execute('where gcloud.cmd', print_output=False)
  else:
    gcloud_path = spawn.find_executable('gcloud')

  if not gcloud_path:
    print('Please install the Google Cloud SDK and set up PATH to point to it.')
    sys.exit(1)

  cloud_sdk_path = os.path.dirname(
      os.path.dirname(os.path.realpath(gcloud_path)))
  appengine_sdk_path = os.path.join(cloud_sdk_path, 'platform',
                                    'google_appengine')
  if not os.path.exists(appengine_sdk_path):
    print('App Engine SDK not found. Please run local/install_deps.bash')
    sys.exit(1)

  return appengine_sdk_path 
开发者ID:google,项目名称:clusterfuzz,代码行数:22,代码来源:appengine.py

示例12: get_command

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def get_command(self, additional_args=None):
    """Overridden get_command."""
    if environment.platform() != 'LINUX':
      raise RuntimeError('UnshareProcessRunner only supported on Linux')

    unshare_path = spawn.find_executable('unshare')
    if not unshare_path:
      raise RuntimeError('unshare not found')

    command = [unshare_path]
    command.extend([
        '-n',  # Enter network namespace.
    ])

    command.append(self._executable_path)
    command.extend(self._default_args)

    if additional_args:
      command.extend(additional_args)

    return command 
开发者ID:google,项目名称:clusterfuzz,代码行数:23,代码来源:new_process.py

示例13: check_executable

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def check_executable(executable):
    """
    Checks if an executable exists in $PATH.

    Arguments:
        executable -- the name of the executable (e.g. "echo")

    Returns:
        True or False
    """
    logger = logging.getLogger(__name__)
    logger.debug("Checking executable '%s'...", executable)
    executable_path = find_executable(executable)
    found = executable_path is not None
    if found:
        logger.debug("Executable '%s' found: '%s'", executable,
                     executable_path)
    else:
        logger.debug("Executable '%s' not found", executable)
    return found 
开发者ID:niutool,项目名称:xuebao,代码行数:22,代码来源:diagnose.py

示例14: _get_c_program

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def _get_c_program(self, makefile_target_name, binary_name):
        """build c program and return path to binary"""
        find_executable(MAKE_CMD)
        if not find_executable(MAKE_CMD):
            print(
                'Could not find executable "%s". Ensure it is installed and on your $PATH.'
                % MAKE_CMD
            )
            exit(1)

        SAMPLE_C_CODE_DIR = os.path.join(
            os.path.dirname(os.path.realpath(__file__)), "sample_c_app"
        )
        binary_path = os.path.join(SAMPLE_C_CODE_DIR, binary_name)
        subprocess.call(["rm", "pygdbmi.a*"], cwd=SAMPLE_C_CODE_DIR)
        # Build C program
        subprocess.check_output(
            [MAKE_CMD, makefile_target_name, "-C", SAMPLE_C_CODE_DIR, "--quiet"]
        )
        return binary_path 
开发者ID:cs01,项目名称:pygdbmi,代码行数:22,代码来源:test_pygdbmi.py

示例15: is_memcached_present

# 需要导入模块: from distutils import spawn [as 别名]
# 或者: from distutils.spawn import find_executable [as 别名]
def is_memcached_present():
    executable = find_executable('memcached')
    return bool(executable) 
开发者ID:cherrypy,项目名称:cherrypy,代码行数:5,代码来源:test_session.py


注:本文中的distutils.spawn.find_executable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。