當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。