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


Python distutils.spawn方法代码示例

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


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

示例1: testDistribute

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import spawn [as 别名]
def testDistribute(self):
        """
        Calls a subprocess to spawn new tests.

        The subprocess is redirected to dev/null (windows <any-dir>\\NUL), to prevent excessive
        output. In order to debug, this test you will likely need to modify this code.
        """
        args = ["mpiexec", "-n", "2", "python", "-m", "unittest"]
        args += ["armi.tests.test_mpiActions.MpiDistributeStateTests"]
        with open(os.devnull, "w") as null:
            # check_call needed because call will just keep going in the event
            # of failures.
            subprocess.check_call(args, stdout=null, stderr=subprocess.STDOUT)


# these two must be defined up here so that they can be pickled 
开发者ID:terrapower,项目名称:armi,代码行数:18,代码来源:test_mpiActions.py

示例2: adb_path

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import spawn [as 别名]
def adb_path(cls):
        """return adb binary full path"""
        if cls.__adb_cmd is None:
            if "ANDROID_HOME" in os.environ:
                filename = "adb.exe" if os.name == 'nt' else "adb"
                adb_dir = os.path.join(os.environ["ANDROID_HOME"], "platform-tools")
                adb_cmd = os.path.join(adb_dir, filename)
                if not os.path.exists(adb_cmd):
                    raise EnvironmentError(
                        "Adb not found in $ANDROID_HOME/platform-tools path: %s." % adb_dir)
            else:
                import distutils
                if "spawn" not in dir(distutils):
                    import distutils.spawn
                adb_cmd = distutils.spawn.find_executable("adb")
                if adb_cmd:
                    adb_cmd = os.path.realpath(adb_cmd)
                else:
                    raise EnvironmentError("$ANDROID_HOME environment not set.")
            cls.__adb_cmd = adb_cmd
        return cls.__adb_cmd 
开发者ID:NetEaseGame,项目名称:ATX,代码行数:23,代码来源:client.py

示例3: adb

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import spawn [as 别名]
def adb(cls):
        """return adb binary full path"""
        if cls.__adb_cmd is None:
            if "ANDROID_HOME" in os.environ:
                filename = "adb.exe" if os.name == 'nt' else "adb"
                adb_cmd = os.path.join(os.environ["ANDROID_HOME"], "platform-tools", filename)
                if not os.path.exists(adb_cmd):
                    raise EnvironmentError(
                        "Adb not found in $ANDROID_HOME path: %s." % os.environ["ANDROID_HOME"])
            else:
                import distutils
                if "spawn" not in dir(distutils):
                    import distutils.spawn
                adb_cmd = distutils.spawn.find_executable("adb")
                if adb_cmd:
                    adb_cmd = os.path.realpath(adb_cmd)
                else:
                    raise EnvironmentError("$ANDROID_HOME environment not set.")
            cls.__adb_cmd = adb_cmd
        return cls.__adb_cmd 
开发者ID:NetEaseGame,项目名称:ATX,代码行数:22,代码来源:adb_old.py

示例4: test_kill_job

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import spawn [as 别名]
def test_kill_job(self):
        with JobRunner.temp_file() as script:
            script.write(b"sleep 30")
            script.close()
            with open(os.devnull, "wb") as devnull:
                r = self.create_runner()
                proc = r.create_process(script.name, {}, devnull)
                r.kill_job(proc)
                self.assertEqual(proc.poll(), -15) # SIGTERM
                proc.wait()
                # get some coverage when the proc is already dead
                r.kill_job(proc)

                # the kill path for windows is different, just get some
                # coverage because we don't currently have a windows box
                # to test on
                with patch.object(platform, 'system') as mock_system:
                    mock_system.side_effect = ["linux", "Windows"]
                    proc = r.create_process(script.name, {}, devnull)
                    r.kill_job(proc)

                    with patch.object(spawn, 'find_executable') as mock_find:
                        mock_system.side_effect = ["Windows"]
                        mock_find.return_value = True
                        r.kill_job(proc)

                # mimic not being able to kill the job
                with patch.object(subprocess.Popen, 'poll') as mock_poll, patch.object(subprocess.Popen, 'kill') as mock_kill:
                    mock_poll.side_effect = [True, None, None]
                    mock_kill.return_value = False
                    proc = r.create_process(script.name, {}, devnull)
                    r.kill_job(proc) 
开发者ID:idaholab,项目名称:civet,代码行数:34,代码来源:test_JobRunner.py

示例5: get_cloud_sync_client

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import spawn [as 别名]
def get_cloud_sync_client(remote_path):
    """Returns a CommandBasedClient that can sync to/from remote storage.

    Args:
        remote_path (str): Path to remote storage (S3 or GS).

    Raises:
        ValueError if malformed remote_dir.
    """
    if remote_path.startswith(S3_PREFIX):
        if not distutils.spawn.find_executable("aws"):
            raise ValueError(
                "Upload uri starting with '{}' requires awscli tool"
                " to be installed".format(S3_PREFIX))
        template = "aws s3 sync {source} {target} --only-show-errors"
        delete_template = "aws s3 rm {target} --recursive --only-show-errors"
    elif remote_path.startswith(GS_PREFIX):
        if not distutils.spawn.find_executable("gsutil"):
            raise ValueError(
                "Upload uri starting with '{}' requires gsutil tool"
                " to be installed".format(GS_PREFIX))
        template = "gsutil rsync -r {source} {target}"
        delete_template = "gsutil rm -r {target}"
    else:
        raise ValueError("Upload uri must start with one of: {}"
                         "".format(ALLOWED_REMOTE_PREFIXES))
    return CommandBasedClient(template, template, delete_template) 
开发者ID:ray-project,项目名称:ray,代码行数:29,代码来源:sync_client.py

示例6: _setup_platform

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import spawn [as 别名]
def _setup_platform():
        """Setup the shell command and the command line argument escape
        function depending on the underlying platform
        """
        global _cmdline2listimpl, _escape_args, _shell_command

        if os._name in _win_oses:
            _cmdline2listimpl = _cmdline2list
            _escape_args = lambda args: [list2cmdline([arg]) for arg in args]
        else:
            _cmdline2listimpl = lambda args: [args]
            _escape_args = lambda args: args

        for shell_command in os._get_shell_commands():
            executable = shell_command[0]
            if not os.path.isabs(executable):
                import distutils.spawn
                executable = distutils.spawn.find_executable(executable)
            if not executable or not os.path.exists(executable):
                continue
            shell_command[0] = executable
            _shell_command = shell_command
            return

        if not _shell_command:
            import warnings
            warnings.warn('Unable to determine _shell_command for '
                          'underlying os: %s' % os._name, RuntimeWarning, 3) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:30,代码来源:subprocess.py

示例7: monkeypatch_condor_submit

# 需要导入模块: import distutils [as 别名]
# 或者: from distutils import spawn [as 别名]
def monkeypatch_condor_submit(monkeypatch):
    # Want to monkeypatch shutil.which to mimic condor_submit existing
    version_major = sys.version_info.major
    version_minor = sys.version_info.minor
    if (version_major, version_minor) >= (3, 3):
        monkeypatch.setattr(shutil, 'which',
                            lambda x: 'submit_exists.exe')
    else:
        monkeypatch.setattr(spawn, 'find_executable',
                            lambda x: 'submit_exists.exe') 
开发者ID:jrbourbeau,项目名称:pycondor,代码行数:12,代码来源:test_job.py


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