• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python util.which函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中rez.util.which函数的典型用法代码示例。如果您正苦于以下问题:Python which函数的具体用法?Python which怎么用?Python which使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: _editor

    def _editor(self):
        ed = os.getenv("EDITOR")
        if ed is None:
            from rez.util import which

            ed = which("vi", "vim", "xdg-open")
        return ed
开发者ID:managani,项目名称:rez,代码行数:7,代码来源:platform_.py


示例2: _terminal_emulator_command

    def _terminal_emulator_command(self):
        term = which("x-terminal-emulator", "xterm")
        if term is None:
            return None

        term = os.path.basename(term)
        if term == "x-terminal-emulator":
            return "%s --noclose -e" % term
        else:
            return "%s -hold -e" % term
开发者ID:instinct-vfx,项目名称:rez,代码行数:10,代码来源:platform_.py


示例3: rez_bin_path

    def rez_bin_path(self):
        """Get path containing rez binaries, or None if no binaries are
        available, or Rez is not a production install.
        """
        binpath = None
        if sys.argv and sys.argv[0]:
            executable = sys.argv[0]
            path = which("rezolve", env={"PATH": os.path.dirname(executable), "PATHEXT": os.environ.get("PATHEXT", "")})
            binpath = os.path.dirname(path) if path else None

        # TODO: improve this, could still pick up non-production 'rezolve'
        if not binpath:
            path = which("rezolve")
            if path:
                binpath = os.path.dirname(path)

        if binpath:
            validation_file = os.path.join(binpath, ".rez_production_install")
            if os.path.exists(validation_file):
                return os.path.realpath(binpath)

        return None
开发者ID:sonictk,项目名称:rez,代码行数:22,代码来源:system.py


示例4: test_rez_env_output

    def test_rez_env_output(self):
        # here we are making sure that running a command via rez-env prints
        # exactly what we expect.
        echo_cmd = which("echo")
        if not echo_cmd:
            print "\nskipping test, 'echo' command not found."
            return

        cmd = [os.path.join(system.rez_bin_path, "rez-env"), "--", "echo", "hey"]
        process = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        sh_out, _ = process.communicate()
        out = str(sh_out).strip()
        self.assertEqual(out, "hey")
开发者ID:instinct-vfx,项目名称:rez,代码行数:13,代码来源:test_shells.py


示例5: test_rez_env_output

    def test_rez_env_output(self):
        # TODO: this test does not run on Windows using the CMD shell as it
        # does not accept commands from stdin.  Rather than explicitly skipping
        # the test (via the decorator) perhaps we should check for startup
        # capabilities as the other tests do.
        from rez.vendor.sh import sh

        # here we are making sure that running a command via rez-env prints
        # exactly what we expect. We use 'sh' because subprocess strips special
        # characters such as color codes - we want to ensure that the output
        # EXACTLY matches the output of the command being run.
        echo_cmd = which("echo")
        if not echo_cmd:
            print "\nskipping test, 'echo' command not found."
            return

        cmd = sh.Command(os.path.join(system.rez_bin_path, "rez-env"))
        sh_out = cmd(["--", "echo", "hey"])
        out = str(sh_out).strip()
        self.assertEqual(out, "hey")
开发者ID:rvsiy,项目名称:rez,代码行数:20,代码来源:test_shells.py


示例6: find_exe

def find_exe(name, filepath=None):
    """Find an executable.

    Args:
        name: Name of the program, eg 'python'.
        filepath: Path to executable, a search is performed if None.

    Returns:
        Path to the executable if found, otherwise an error is raised.
    """
    if filepath:
        if not os.path.exists(filepath):
            open(filepath)  # raise IOError
        elif not os.path.isfile(filepath):
            raise RezBindError("not a file: %s" % filepath)
    else:
        filepath = which(name)
        if not filepath:
            raise RezBindError("could not find executable: %s" % name)

    return filepath
开发者ID:RovioAnimation,项目名称:rez,代码行数:21,代码来源:_utils.py


示例7: execute_command

    def execute_command(self, cmd_name, cmd_arguments, user, errors, env=None):
        def _err(msg):
            errors.append(msg)
            if self.settings.print_error:
                print >> sys.stderr, msg

        kwargs = {}
        if env:
            kwargs["env"] = env

        def _execute(commands):
            process = Popen(commands, stdout=PIPE, stderr=STDOUT, **kwargs)
            stdout, _ = process.communicate()

            if process.returncode != 0:
                msg = "command failed:\n%s" % stdout
                _err(msg)
                return False
            if self.settings.print_output:
                print stdout.strip()
            return True

        if not os.path.isfile(cmd_name):
            cmd_full_path = which(cmd_name)
        else:
            cmd_full_path = cmd_name
        if not cmd_full_path:
            msg = "%s: command not found" % cmd_name
            _err(msg)
            return False

        cmds = [cmd_full_path] + (cmd_arguments or [])
        if user == 'root':
            cmds = ['sudo'] + cmds
            return _execute(cmds)
        elif user and user != getpass.getuser():
            raise NotImplementedError  # TODO
        else:
            return _execute(cmds)
开发者ID:Pixomondo,项目名称:rez,代码行数:39,代码来源:command.py


示例8: _difftool

 def _difftool(self):
     # although meld would be preferred, fc ships with all Windows versions back to DOS
     from rez.util import which
     return which("meld", "fc")
开发者ID:instinct-vfx,项目名称:rez,代码行数:4,代码来源:platform_.py


示例9: _image_viewer

 def _image_viewer(self):
     from rez.util import which
     return which("xdg-open", "eog", "kview")
开发者ID:instinct-vfx,项目名称:rez,代码行数:3,代码来源:platform_.py


示例10: find_executable

 def find_executable(cls, name):
     exe = which(name)
     if not exe:
         raise RuntimeError("Couldn't find executable '%s'." % name)
     return exe
开发者ID:rvsiy,项目名称:rez,代码行数:5,代码来源:shells.py


示例11: find_executable

 def find_executable(cls, name):
     exe = which(name)
     if not exe:
         raise ReleaseVCSError("Couldn't find executable '%s' for VCS '%s'"
                               % (name, cls.name()))
     return exe
开发者ID:Pixomondo,项目名称:rez,代码行数:6,代码来源:release_vcs.py


示例12: _difftool

 def _difftool(self):
     return which("kdiff3", "meld", "diff")
开发者ID:mottosso,项目名称:rez,代码行数:2,代码来源:platform_.py


示例13: _editor

 def _editor(self):
     ed = os.getenv("EDITOR")
     if ed is None:
         ed = which("xdg-open", "vim", "vi")
     return ed
开发者ID:mottosso,项目名称:rez,代码行数:5,代码来源:platform_.py


示例14: _image_viewer

 def _image_viewer(self):
     return which("xdg-open", "eog", "kview")
开发者ID:mottosso,项目名称:rez,代码行数:2,代码来源:platform_.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python logging_.print_warning函数代码示例发布时间:2022-05-26
下一篇:
Python util.TempdirMixin类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap