diff options
author | cookedm <cookedm@localhost> | 2006-02-01 22:55:38 +0000 |
---|---|---|
committer | cookedm <cookedm@localhost> | 2006-02-01 22:55:38 +0000 |
commit | 9a794fa867d664aaf85a82be2c7fadf2b7d5fe21 (patch) | |
tree | d01d2fc9ca49111b7662497e1162e0120c68f12d /numpy/distutils/exec_command.py | |
parent | c0f4676426b86daa235331ed14720eaf7f7d461d (diff) | |
download | numpy-9a794fa867d664aaf85a82be2c7fadf2b7d5fe21.tar.gz |
Replace type(a) is (something) with appropiate is_string/is_sequence tests
Diffstat (limited to 'numpy/distutils/exec_command.py')
-rw-r--r-- | numpy/distutils/exec_command.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index a44fd9abf..43ec4bf4e 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -53,6 +53,8 @@ import re import sys import tempfile +from numpy.distutils.misc_util import is_sequence + ############################################################ from log import _global_log as log @@ -269,8 +271,8 @@ def _exec_command_posix( command, **env ): log.debug('_exec_command_posix(...)') - if type(command) is type([]): - command_str = ' '.join(command) + if is_sequence(command): + command_str = ' '.join(list(command)) else: command_str = command @@ -312,7 +314,7 @@ def _exec_command_posix( command, if text[-1:]=='\n': text = text[:-1] - + return status, text @@ -348,12 +350,12 @@ def _exec_command_python(command, status = int(f.read()) f.close() os.remove(stsfile) - + f = open(outfile,'r') text = f.read() f.close() os.remove(outfile) - + return status, text def quote_arg(arg): @@ -363,7 +365,7 @@ def quote_arg(arg): def _exec_command( command, use_shell=None, use_tee = None, **env ): log.debug('_exec_command(...)') - + if use_shell is None: use_shell = os.name=='posix' if use_tee is None: @@ -374,14 +376,14 @@ def _exec_command( command, use_shell=None, use_tee = None, **env ): # We use shell (unless use_shell==0) so that wildcards can be # used. sh = os.environ.get('SHELL','/bin/sh') - if type(command) is type([]): - argv = [sh,'-c',' '.join(command)] + if is_sequence(command): + argv = [sh,'-c',' '.join(list(command))] else: argv = [sh,'-c',command] else: # On NT, DOS we avoid using command.com as it's exit status is # not related to the exit status of a command. - if type(command) is type([]): + if is_sequence(command): argv = command[:] else: argv = splitcmdline(command) @@ -483,7 +485,7 @@ def test_nt(**kws): s,o=exec_command(pythonexe\ +' -c "import os;print os.environ.get(\'AAA\',\'\')"') assert s==0 and o=='',(s,o) - + s,o=exec_command(pythonexe\ +' -c "import os;print os.environ.get(\'AAA\')"', AAA='Tere') @@ -529,7 +531,7 @@ def test_nt(**kws): s,o=exec_command('echo path=%path%') assert s==0 and o!='',(s,o) - + s,o=exec_command('%s -c "import sys;sys.stderr.write(sys.platform)"' \ % pythonexe) assert s==0 and o=='win32',(s,o) @@ -579,7 +581,7 @@ def test_posix(**kws): s,o=exec_command('echo path=$PATH',**kws) assert s==0 and o!='',(s,o) - + s,o=exec_command('python -c "import sys,os;sys.stderr.write(os.name)"',**kws) assert s==0 and o=='posix',(s,o) @@ -594,7 +596,7 @@ def test_posix(**kws): s,o=exec_command('python -c "print \'Heipa\'"',**kws) assert s==0 and o=='Heipa',(s,o) - + print 'ok' def test_execute_in(**kws): |