本文整理汇总了Python中numpy.distutils.exec_command.exec_command函数的典型用法代码示例。如果您正苦于以下问题:Python exec_command函数的具体用法?Python exec_command怎么用?Python exec_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exec_command函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: check_nt
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')
开发者ID:AlerzDev,项目名称:Brazo-Proyecto-Final,代码行数:9,代码来源:test_exec_command.py
示例2: check_nt
def check_nt(self, **kws):
s, o = exec_command.exec_command('cmd /C echo path=%path%')
self.assertEqual(s, 0)
self.assertNotEqual(o, '')
s, o = exec_command.exec_command(
'"%s" -c "import sys;sys.stderr.write(sys.platform)"' % self.pyexe)
self.assertEqual(s, 0)
self.assertEqual(o, 'win32')
开发者ID:BranYang,项目名称:numpy,代码行数:9,代码来源:test_exec_command.py
示例3: test_exec_command_stderr
def test_exec_command_stderr():
# Test posix version:
with redirect_stdout(TemporaryFile()):
with redirect_stderr(StringIO.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.StringIO()):
exec_command.exec_command("cd '.'")
开发者ID:dkj142857,项目名称:numpy,代码行数:12,代码来源:test_exec_command.py
示例4: test_exec_command_stderr
def test_exec_command_stderr():
# Test posix version:
with redirect_stdout(TemporaryFile(mode='w+')):
with redirect_stderr(StringIO()):
with assert_warns(DeprecationWarning):
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()):
with assert_warns(DeprecationWarning):
exec_command.exec_command("cd '.'")
开发者ID:anntzer,项目名称:numpy,代码行数:14,代码来源:test_exec_command.py
示例5: get_version
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 = os.listdir(xlf_dir)
l.sort()
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
开发者ID:glimmercn,项目名称:numpy,代码行数:26,代码来源:ibm.py
示例6: run
def run(self):
mandir = os.path.join(self.build_base, 'man')
self.mkpath(mandir)
from pkg_resources import iter_entry_points
for entrypoint in iter_entry_points(group='console_scripts'):
if not entrypoint.module_name.startswith('obspy'):
continue
output = os.path.join(mandir, entrypoint.name + '.1')
print('Generating %s ...' % (output))
exec_command([self.help2man,
'--no-info', '--no-discard-stderr',
'--output', output,
'"%s -m %s"' % (sys.executable,
entrypoint.module_name)])
开发者ID:marcopovitch,项目名称:obspy,代码行数:16,代码来源:setup.py
示例7: get_libgcc_dir
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
开发者ID:chadnetzer,项目名称:numpy-gaurdro,代码行数:7,代码来源:gnu.py
示例8: compile
def compile(source,
modulename = 'untitled',
extra_args = '',
verbose = 1,
source_fn = None
):
''' Build extension module from processing source with f2py.
Read the source of this function for more information.
'''
from numpy.distutils.exec_command import exec_command
import tempfile
if source_fn is None:
f = tempfile.NamedTemporaryFile(suffix='.f')
else:
f = open(source_fn, 'w')
try:
f.write(source)
f.flush()
args = ' -c -m %s %s %s'%(modulename, f.name, extra_args)
c = '%s -c "import numpy.f2py as f2py2e;f2py2e.main()" %s' % \
(sys.executable, args)
s, o = exec_command(c)
finally:
f.close()
return s
开发者ID:7924102,项目名称:numpy,代码行数:27,代码来源:__init__.py
示例9: execute
def execute(self, *args):
"""
Run generated setup.py file with given arguments.
"""
if not args:
raise ValueError('need setup.py arguments')
self.debug(self.generate(dry_run=False))
cmd = [sys.executable,'setup.py'] + list(args)
self.debug('entering %r directory' % (self.path))
self.debug('executing command %r' % (' '.join(cmd)))
try:
r = exec_command(cmd, execute_in=self.path, use_tee=False)
except:
self.info('leaving %r directory' % (self.path))
raise
else:
try:
self._show_warnings_errors(r[1])
except Exception, msg:
#print msg
self.warning(r[1])
if not r[0]:
self.debug('SUCCESS!')
else:
self.warning('FAILURE')
self.debug('leaving %r directory' % (self.path))
开发者ID:dagss,项目名称:f2py-g3,代码行数:26,代码来源:setup_py.py
示例10: get_target
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 ""
开发者ID:seyatutome,项目名称:distnumpy,代码行数:7,代码来源:gnu.py
示例11: get_output
def get_output(self, body, headers=None, include_dirs=None,
libraries=None, library_dirs=None,
lang="c"):
"""Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Returns the exit status code
of the program and its output.
"""
from distutils.ccompiler import CompileError, LinkError
self._check_compiler()
exitcode, output = 255, ''
try:
src, obj, exe = self._link(body, headers, include_dirs,
libraries, library_dirs, lang)
exe = os.path.join('.', exe)
exitstatus, output = exec_command(exe, execute_in='.')
if hasattr(os, 'WEXITSTATUS'):
exitcode = os.WEXITSTATUS(exitstatus)
if os.WIFSIGNALED(exitstatus):
sig = os.WTERMSIG(exitstatus)
log.error('subprocess exited with signal %d' % (sig,))
if sig == signal.SIGINT:
# control-C
raise KeyboardInterrupt
else:
exitcode = exitstatus
log.info("success!")
except (CompileError, LinkError):
log.info("failure.")
self._clean()
return exitcode, output
开发者ID:radical-software,项目名称:radicalspam,代码行数:31,代码来源:config.py
示例12: CCompiler_get_version
def CCompiler_get_version(self, force=0, ok_status=[0]):
""" Compiler version. Returns None if compiler is not available. """
if not force and hasattr(self,'version'):
return self.version
try:
version_cmd = self.version_cmd
except AttributeError:
return None
cmd = ' '.join(version_cmd)
try:
matcher = self.version_match
except AttributeError:
try:
pat = self.version_pattern
except AttributeError:
return None
def matcher(version_string):
m = re.match(pat, version_string)
if not m:
return None
version = m.group('version')
return version
status, output = exec_command(cmd,use_tee=0)
version = None
if status in ok_status:
version = matcher(output)
if not version:
log.warn("Couldn't match compiler version for %r" % (output,))
else:
version = LooseVersion(version)
self.version = version
return version
开发者ID:jackygrahamez,项目名称:DrugDiscovery-Home,代码行数:33,代码来源:ccompiler.py
示例13: CCompiler_get_version
def CCompiler_get_version(self, force=False, ok_status=[0]):
"""Compiler version. Returns None if compiler is not available."""
if not force and hasattr(self,'version'):
return self.version
self.find_executables()
try:
version_cmd = self.version_cmd
except AttributeError:
return None
if not version_cmd or not version_cmd[0]:
return None
try:
matcher = self.version_match
except AttributeError:
try:
pat = self.version_pattern
except AttributeError:
return None
def matcher(version_string):
m = re.match(pat, version_string)
if not m:
return None
version = m.group('version')
return version
status, output = exec_command(version_cmd,use_tee=0)
version = None
if status in ok_status:
version = matcher(output)
if version:
version = LooseVersion(version)
self.version = version
return version
开发者ID:wolfgarnet,项目名称:numpycbe,代码行数:34,代码来源:ccompiler.py
示例14: compile
def compile(source,
modulename = 'untitled',
extra_args = '',
verbose = 1,
source_fn = None
):
''' Build extension module from processing source with f2py.
Read the source of this function for more information.
'''
from numpy.distutils.exec_command import exec_command
import tempfile
if source_fn is None:
fname = os.path.join(tempfile.mktemp()+'.f')
else:
fname = source_fn
f = open(fname, 'w')
f.write(source)
f.close()
args = ' -c -m %s %s %s'%(modulename, fname, extra_args)
c = '%s -c "import numpy.f2py as f2py2e;f2py2e.main()" %s' %(sys.executable, args)
s, o = exec_command(c)
if source_fn is None:
try: os.remove(fname)
except OSError: pass
return s
开发者ID:Alanchi,项目名称:numpy,代码行数:27,代码来源:__init__.py
示例15: run
def run(self):
mandir = os.path.join(self.build_base, 'man')
self.mkpath(mandir)
from pkg_resources import EntryPoint
for entrypoint in ENTRY_POINTS['console_scripts']:
ep = EntryPoint.parse(entrypoint)
if not ep.module_name.startswith('obspy'):
continue
output = os.path.join(mandir, ep.name + '.1')
print('Generating %s ...' % (output))
exec_command([self.help2man,
'--no-info', '--no-discard-stderr',
'--output', output,
'"%s -m %s"' % (sys.executable,
ep.module_name)])
开发者ID:peace001,项目名称:obspy,代码行数:17,代码来源:setup.py
示例16: spawn
def spawn(self, cmd, display=None):
if type(cmd) is type([]) and os.name == 'nt':
cmd = _nt_quote_args(cmd)
s,o = exec_command(cmd, use_tee=0)
if s:
from distutils.ccompiler import DistutilsExecError
raise DistutilsExecError,\
'Command "%s" failed with exit status %d' % (cmd, s)
开发者ID:mbentz80,项目名称:jzigbeercp,代码行数:8,代码来源:config_pygist.py
示例17: check_execute_in
def check_execute_in(self, **kws):
with tempdir() as tmpdir:
fn = "file"
tmpfile = os.path.join(tmpdir, fn)
f = open(tmpfile, 'w')
f.write('Hello')
f.close()
s, o = exec_command.exec_command(
'"%s" -c "f = open(\'%s\', \'r\'); f.close()"' %
(self.pyexe, fn), **kws)
assert_(s != 0)
assert_(o != '')
s, o = exec_command.exec_command(
'"%s" -c "f = open(\'%s\', \'r\'); print(f.read()); '
'f.close()"' % (self.pyexe, fn), execute_in=tmpdir, **kws)
assert_(s == 0)
assert_(o == 'Hello')
开发者ID:AlerzDev,项目名称:Brazo-Proyecto-Final,代码行数:18,代码来源:test_exec_command.py
示例18: _libs_with_msvc_and_fortran
def _libs_with_msvc_and_fortran(self, fcompiler, c_libraries,
c_library_dirs):
if fcompiler is None:
return
for libname in c_libraries:
if libname.startswith('msvc'):
continue
fileexists = False
for libdir in c_library_dirs or []:
libfile = os.path.join(libdir, '%s.lib' % (libname))
if os.path.isfile(libfile):
fileexists = True
break
if fileexists:
continue
# make g77-compiled static libs available to MSVC
fileexists = False
for libdir in c_library_dirs:
libfile = os.path.join(libdir, 'lib%s.a' % (libname))
if os.path.isfile(libfile):
# copy libname.a file to name.lib so that MSVC linker
# can find it
libfile2 = os.path.join(self.build_temp, libname + '.lib')
copy_file(libfile, libfile2)
if self.build_temp not in c_library_dirs:
c_library_dirs.append(self.build_temp)
fileexists = True
break
if fileexists:
continue
log.warn('could not find library %r in directories %s'
% (libname, c_library_dirs))
# Always use system linker when using MSVC compiler.
f_lib_dirs = []
for dir in fcompiler.library_dirs:
# correct path when compiling in Cygwin but with normal Win
# Python
if dir.startswith('/usr/lib'):
s, o = exec_command(['cygpath', '-w', dir], use_tee=False)
if not s:
dir = o
f_lib_dirs.append(dir)
c_library_dirs.extend(f_lib_dirs)
# make g77-compiled static libs available to MSVC
for lib in fcompiler.libraries:
if not lib.startswith('msvc'):
c_libraries.append(lib)
p = combine_paths(f_lib_dirs, 'lib' + lib + '.a')
if p:
dst_name = os.path.join(self.build_temp, lib + '.lib')
if not os.path.isfile(dst_name):
copy_file(p[0], dst_name)
if self.build_temp not in c_library_dirs:
c_library_dirs.append(self.build_temp)
开发者ID:Jengel1,项目名称:SunriseSunsetTimeFinder,代码行数:57,代码来源:build_ext.py
示例19: target_architecture
def target_architecture(self, extra_opts=()):
"""Return the architecture that the compiler will build for.
This is most useful for detecting universal compilers in OS X."""
extra_opts = list(extra_opts)
status, output = exec_command(self.compiler_f90 + ['-v'] + extra_opts,
use_tee=False)
if status == 0:
m = re.match(r'(?m)^Target: (.*)$', output)
if m:
return m.group(1)
return None
开发者ID:zoccolan,项目名称:eyetracker,代码行数:11,代码来源:gnu.py
示例20: test_exec_command_stdout
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.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.StringIO()):
with redirect_stderr(TemporaryFile()):
exec_command.exec_command("cd '.'")
开发者ID:dkj142857,项目名称:numpy,代码行数:21,代码来源:test_exec_command.py
注:本文中的numpy.distutils.exec_command.exec_command函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论