當前位置: 首頁>>代碼示例>>Python>>正文


Python spawn.spawn方法代碼示例

本文整理匯總了Python中distutils.spawn.spawn方法的典型用法代碼示例。如果您正苦於以下問題:Python spawn.spawn方法的具體用法?Python spawn.spawn怎麽用?Python spawn.spawn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在distutils.spawn的用法示例。


在下文中一共展示了spawn.spawn方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_spawn

# 需要導入模塊: from distutils import spawn [as 別名]
# 或者: from distutils.spawn import spawn [as 別名]
def test_spawn(self):
        tmpdir = self.mkdtemp()

        # creating something executable
        # through the shell that returns 1
        if os.name == 'posix':
            exe = os.path.join(tmpdir, 'foo.sh')
            self.write_file(exe, '#!/bin/sh\nexit 1')
        else:
            exe = os.path.join(tmpdir, 'foo.bat')
            self.write_file(exe, 'exit 1')

        os.chmod(exe, 0o777)
        self.assertRaises(DistutilsExecError, spawn, [exe])

        # now something that works
        if os.name == 'posix':
            exe = os.path.join(tmpdir, 'foo.sh')
            self.write_file(exe, '#!/bin/sh\nexit 0')
        else:
            exe = os.path.join(tmpdir, 'foo.bat')
            self.write_file(exe, 'exit 0')

        os.chmod(exe, 0o777)
        spawn([exe])  # should work without any error 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:27,代碼來源:test_spawn.py

示例2: test_spawn

# 需要導入模塊: from distutils import spawn [as 別名]
# 或者: from distutils.spawn import spawn [as 別名]
def test_spawn(self):
        tmpdir = self.mkdtemp()

        # creating something executable
        # through the shell that returns 1
        if sys.platform != 'win32':
            exe = os.path.join(tmpdir, 'foo.sh')
            self.write_file(exe, '#!%s\nexit 1' % unix_shell)
        else:
            exe = os.path.join(tmpdir, 'foo.bat')
            self.write_file(exe, 'exit 1')

        os.chmod(exe, 0o777)
        self.assertRaises(DistutilsExecError, spawn, [exe])

        # now something that works
        if sys.platform != 'win32':
            exe = os.path.join(tmpdir, 'foo.sh')
            self.write_file(exe, '#!%s\nexit 0' % unix_shell)
        else:
            exe = os.path.join(tmpdir, 'foo.bat')
            self.write_file(exe, 'exit 0')

        os.chmod(exe, 0o777)
        spawn([exe])  # should work without any error 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:27,代碼來源:test_spawn.py

示例3: build_extensions

# 需要導入模塊: from distutils import spawn [as 別名]
# 或者: from distutils.spawn import spawn [as 別名]
def build_extensions(self):
        self.compiler.src_extensions.append('.cu')
        self.compiler.set_executable('compiler_so', 'nvcc')
        self.compiler.set_executable('linker_so', 'nvcc --shared')
        if hasattr(self.compiler, '_c_extensions'):
            self.compiler._c_extensions.append('.cu')  # needed for Windows
        self.compiler.spawn = self.spawn
        build_ext.build_extensions(self) 
開發者ID:tonysy,項目名稱:Deep-Feature-Flow-Segmentation,代碼行數:10,代碼來源:setup_windows_cuda.py

示例4: spawn

# 需要導入模塊: from distutils import spawn [as 別名]
# 或者: from distutils.spawn import spawn [as 別名]
def spawn (self, cmd, search_path=1, level=1):
        """Spawn an external command respecting dry-run flag."""
        from distutils.spawn import spawn
        spawn(cmd, search_path, dry_run= self.dry_run) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:6,代碼來源:cmd.py

示例5: spawn

# 需要導入模塊: from distutils import spawn [as 別名]
# 或者: from distutils.spawn import spawn [as 別名]
def spawn(self, cmd):
        spawn(cmd, dry_run=self.dry_run) 
開發者ID:glmcdona,項目名稱:meddle,代碼行數:4,代碼來源:ccompiler.py

示例6: test_spawn

# 需要導入模塊: from distutils import spawn [as 別名]
# 或者: from distutils.spawn import spawn [as 別名]
def test_spawn(self):
        tmpdir = self.mkdtemp()

        # creating something executable
        # through the shell that returns 1
        if os.name == 'posix':
            exe = os.path.join(tmpdir, 'foo.sh')
            self.write_file(exe, '#!/bin/sh\nexit 1')
            os.chmod(exe, 0777)
        else:
            exe = os.path.join(tmpdir, 'foo.bat')
            self.write_file(exe, 'exit 1')

        os.chmod(exe, 0777)
        self.assertRaises(DistutilsExecError, spawn, [exe])

        # now something that works
        if os.name == 'posix':
            exe = os.path.join(tmpdir, 'foo.sh')
            self.write_file(exe, '#!/bin/sh\nexit 0')
            os.chmod(exe, 0777)
        else:
            exe = os.path.join(tmpdir, 'foo.bat')
            self.write_file(exe, 'exit 0')

        os.chmod(exe, 0777)
        spawn([exe])  # should work without any error 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:29,代碼來源:test_spawn.py

示例7: spawn

# 需要導入模塊: from distutils import spawn [as 別名]
# 或者: from distutils.spawn import spawn [as 別名]
def spawn(self, cmd, search_path=1, level=1):
        """Spawn an external command respecting dry-run flag."""
        from distutils.spawn import spawn
        spawn(cmd, search_path, dry_run=self.dry_run) 
開發者ID:Microvellum,項目名稱:Fluid-Designer,代碼行數:6,代碼來源:cmd.py

示例8: test_find_executable

# 需要導入模塊: from distutils import spawn [as 別名]
# 或者: from distutils.spawn import spawn [as 別名]
def test_find_executable(self):
        with test_support.temp_dir() as tmp_dir:
            # use TESTFN to get a pseudo-unique filename
            program_noeext = test_support.TESTFN
            # Give the temporary program an ".exe" suffix for all.
            # It's needed on Windows and not harmful on other platforms.
            program = program_noeext + ".exe"

            filename = os.path.join(tmp_dir, program)
            with open(filename, "wb"):
                pass
            os.chmod(filename, stat.S_IXUSR)

            # test path parameter
            rv = find_executable(program, path=tmp_dir)
            self.assertEqual(rv, filename)

            if sys.platform == 'win32':
                # test without ".exe" extension
                rv = find_executable(program_noeext, path=tmp_dir)
                self.assertEqual(rv, filename)

            # test find in the current directory
            with test_support.change_cwd(tmp_dir):
                rv = find_executable(program)
                self.assertEqual(rv, program)

            # test non-existent program
            dont_exist_program = "dontexist_" + program
            rv = find_executable(dont_exist_program , path=tmp_dir)
            self.assertIsNone(rv)

            # test os.defpath: missing PATH environment variable
            with test_support.EnvironmentVarGuard() as env:
                with mock.patch('distutils.spawn.os.defpath', tmp_dir):
                    env.pop('PATH')

                    rv = find_executable(program)
                    self.assertEqual(rv, filename) 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:41,代碼來源:test_spawn.py


注:本文中的distutils.spawn.spawn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。