本文整理匯總了Python中numpy.distutils.exec_command.exec_command方法的典型用法代碼示例。如果您正苦於以下問題:Python exec_command.exec_command方法的具體用法?Python exec_command.exec_command怎麽用?Python exec_command.exec_command使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.distutils.exec_command
的用法示例。
在下文中一共展示了exec_command.exec_command方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_exec_command_stdout
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def test_exec_command_stdout():
# Regression test for gh-2999 and gh-2915.
# There are several packages (nose, scipy.weave.inline, Sage inline
# Fortran) that replace stdout, in which case it doesn't have a fileno
# method. This is tested here, with a do-nothing command that fails if the
# presence of fileno() is assumed in exec_command.
# The code has a special case for posix systems, so if we are on posix test
# both that the special case works and that the generic code works.
# Test posix version:
with redirect_stdout(StringIO()):
with redirect_stderr(TemporaryFile()):
exec_command.exec_command("cd '.'")
if os.name == 'posix':
# Test general (non-posix) version:
with emulate_nonposix():
with redirect_stdout(StringIO()):
with redirect_stderr(TemporaryFile()):
exec_command.exec_command("cd '.'")
示例2: check_basic
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def check_basic(self, *kws):
s, o = exec_command.exec_command(
'"%s" -c "raise \'Ignore me.\'"' % self.pyexe, **kws)
assert_(s != 0)
assert_(o != '')
s, o = exec_command.exec_command(
'"%s" -c "import sys;sys.stderr.write(\'0\');'
'sys.stderr.write(\'1\');sys.stderr.write(\'2\')"' %
self.pyexe, **kws)
assert_(s == 0)
assert_(o == '012')
s, o = exec_command.exec_command(
'"%s" -c "import sys;sys.exit(15)"' % self.pyexe, **kws)
assert_(s == 15)
assert_(o == '')
s, o = exec_command.exec_command(
'"%s" -c "print(\'Heipa\'")' % self.pyexe, **kws)
assert_(s == 0)
assert_(o == 'Heipa')
示例3: get_libgfortran_dir
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def get_libgfortran_dir(self):
if sys.platform[:5] == 'linux':
libgfortran_name = 'libgfortran.so'
elif sys.platform == 'darwin':
libgfortran_name = 'libgfortran.dylib'
else:
libgfortran_name = None
libgfortran_dir = None
if libgfortran_name:
find_lib_arg = ['-print-file-name={0}'.format(libgfortran_name)]
status, output = exec_command(
self.compiler_f77 + find_lib_arg, use_tee=0)
if not status:
libgfortran_dir = os.path.dirname(output)
return libgfortran_dir
示例4: get_version
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def get_version(self,*args,**kwds):
version = FCompiler.get_version(self,*args,**kwds)
if version is None and sys.platform.startswith('aix'):
# use lslpp to find out xlf version
lslpp = find_executable('lslpp')
xlf = find_executable('xlf')
if os.path.exists(xlf) and os.path.exists(lslpp):
s, o = exec_command(lslpp + ' -Lc xlfcmp')
m = re.search(r'xlfcmp:(?P<version>\d+([.]\d+)+)', o)
if m: version = m.group('version')
xlf_dir = '/etc/opt/ibmcmp/xlf'
if version is None and os.path.isdir(xlf_dir):
# linux:
# If the output of xlf does not contain version info
# (that's the case with xlf 8.1, for instance) then
# let's try another method:
l = sorted(os.listdir(xlf_dir))
l.reverse()
l = [d for d in l if os.path.isfile(os.path.join(xlf_dir, d, 'xlf.cfg'))]
if l:
from distutils.version import LooseVersion
self.version = version = LooseVersion(l[0])
return version
示例5: get_version
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def get_version(self,*args,**kwds):
version = FCompiler.get_version(self,*args,**kwds)
if version is None and sys.platform.startswith('aix'):
# use lslpp to find out xlf version
lslpp = find_executable('lslpp')
xlf = find_executable('xlf')
if os.path.exists(xlf) and os.path.exists(lslpp):
s, o = exec_command(lslpp + ' -Lc xlfcmp')
m = re.search('xlfcmp:(?P<version>\d+([.]\d+)+)', o)
if m: version = m.group('version')
xlf_dir = '/etc/opt/ibmcmp/xlf'
if version is None and os.path.isdir(xlf_dir):
# linux:
# If the output of xlf does not contain version info
# (that's the case with xlf 8.1, for instance) then
# let's try another method:
l = sorted(os.listdir(xlf_dir))
l.reverse()
l = [d for d in l if os.path.isfile(os.path.join(xlf_dir, d, 'xlf.cfg'))]
if l:
from distutils.version import LooseVersion
self.version = version = LooseVersion(l[0])
return version
示例6: test_exec_command_stderr
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def test_exec_command_stderr():
# Test posix version:
with redirect_stdout(TemporaryFile(mode='w+')):
with redirect_stderr(StringIO()):
exec_command.exec_command("cd '.'")
if os.name == 'posix':
# Test general (non-posix) version:
with emulate_nonposix():
with redirect_stdout(TemporaryFile()):
with redirect_stderr(StringIO()):
exec_command.exec_command("cd '.'")
示例7: check_nt
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def check_nt(self, **kws):
s, o = exec_command.exec_command('cmd /C echo path=%path%')
assert_(s == 0)
assert_(o != '')
s, o = exec_command.exec_command(
'"%s" -c "import sys;sys.stderr.write(sys.platform)"' % self.pyexe)
assert_(s == 0)
assert_(o == 'win32')
示例8: CCompiler_spawn
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def CCompiler_spawn(self, cmd, display=None):
"""
Execute a command in a sub-process.
Parameters
----------
cmd : str
The command to execute.
display : str or sequence of str, optional
The text to add to the log file kept by `numpy.distutils`.
If not given, `display` is equal to `cmd`.
Returns
-------
None
Raises
------
DistutilsExecError
If the command failed, i.e. the exit status was not 0.
"""
if display is None:
display = cmd
if is_sequence(display):
display = ' '.join(list(display))
log.info(display)
s, o = exec_command(cmd)
if s:
if is_sequence(cmd):
cmd = ' '.join(list(cmd))
try:
print(o)
except UnicodeError:
# When installing through pip, `o` can contain non-ascii chars
pass
if re.search('Too many open files', o):
msg = '\nTry rerunning setup command until build succeeds.'
else:
msg = ''
raise DistutilsExecError('Command "%s" failed with exit status %d%s' % (cmd, s, msg))
示例9: get_libgcc_dir
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def get_libgcc_dir(self):
status, output = exec_command(
self.compiler_f77 + ['-print-libgcc-file-name'], use_tee=0)
if not status:
return os.path.dirname(output)
return None
示例10: get_target
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def get_target(self):
status, output = exec_command(self.compiler_f77 + ['-v'], use_tee=0)
if not status:
m = TARGET_R.search(output)
if m:
return m.group(1)
return ""
示例11: get_libgcc_dir
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def get_libgcc_dir(self):
status, output = exec_command(self.compiler_f77 +
['-print-libgcc-file-name'],
use_tee=0)
if not status:
return os.path.dirname(output)
return None
示例12: get_target
# 需要導入模塊: from numpy.distutils import exec_command [as 別名]
# 或者: from numpy.distutils.exec_command import exec_command [as 別名]
def get_target(self):
status, output = exec_command(self.compiler_f77 +
['-v'],
use_tee=0)
if not status:
m = TARGET_R.search(output)
if m:
return m.group(1)
return ""