%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/
Upload File :
Create Path :
Current File : //proc/self/root/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyo

�
�9Zc@`s�dZddlmZmZmZddgZddlZddlZddlZddl	m
Z
mZddlm
Z
ddlmZdd	lmZd
�Zd�Zdid�Zd
�Zd�Zd�Zddddd�Zddd�Zdd�Zd�Zddd�Zd�Zd�Zd�Z d�Z!d�Z"ej#dkraeZ$n*ej#d"kryeZ$ne%dej#��e&d kr�e$d!d�e$d!d�e d!d�e d!d�e!d!d�e"d!d�ndS(#s/
exec_command

Implements exec_command function that is (almost) equivalent to
commands.getstatusoutput function but on NT, DOS systems the
returned status is actually correct (though, the returned status
values may be different by a factor). In addition, exec_command
takes keyword arguments for (re-)defining environment variables.

Provides functions:

  exec_command  --- execute command in a specified directory and
                    in the modified environment.
  find_executable --- locate a command using info from environment
                    variable PATH. Equivalent to posix `which`
                    command.

Author: Pearu Peterson <pearu@cens.ioc.ee>
Created: 11 January 2003

Requires: Python 2.x

Succesfully tested on:

========  ============  =================================================
os.name   sys.platform  comments
========  ============  =================================================
posix     linux2        Debian (sid) Linux, Python 2.1.3+, 2.2.3+, 2.3.3
                        PyCrust 0.9.3, Idle 1.0.2
posix     linux2        Red Hat 9 Linux, Python 2.1.3, 2.2.2, 2.3.2
posix     sunos5        SunOS 5.9, Python 2.2, 2.3.2
posix     darwin        Darwin 7.2.0, Python 2.3
nt        win32         Windows Me
                        Python 2.3(EE), Idle 1.0, PyCrust 0.7.2
                        Python 2.1.1 Idle 0.8
nt        win32         Windows 98, Python 2.1.1. Idle 0.8
nt        win32         Cygwin 98-4.10, Python 2.1.1(MSC) - echo tests
                        fail i.e. redefining environment variables may
                        not work. FIXED: don't use cygwin echo!
                        Comment: also `cmd /c echo` will not work
                        but redefining environment variables do work.
posix     cygwin        Cygwin 98-4.10, Python 2.3.3(cygming special)
nt        win32         Windows XP, Python 2.3.3
========  ============  =================================================

Known bugs:

* Tests, that send messages to stderr, fail when executed from MSYS prompt
  because the messages are lost at some point.

i(tdivisiontabsolute_importtprint_functiontexec_commandtfind_executableN(tis_sequencetmake_temp_file(tlog(t
get_exception(topen_latin1cC`st�\}}|j�|S(N(Rtclose(tfotname((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyttemp_file_nameBs
cC`sdtj}tjdkr`tjj|�\}}|j�jdd�}tjj||�}n|S(NtnttdostPYTHONWtPYTHON(RR(	tsyst
executabletosRtpathtsplittuppertreplacetjoin(t	pythonexetfdirtfn((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyt
get_pythonexeGs	cC`s||f}y||SWntk
r+nXtjd|�|}|dkrjtjjdtj�}ntjdkr�tj	j
}n	d�}|jd�r�|dd!}ndg}tjdkr
tj	j|�\}}dd
dg}	|j
�|	kr
|	}q
ntj	j|�r+dg}
n1g|jtj�D]}tj	j|�^q>}
x�|
D]�}tj	j||�}x|D]w}||}
tj	j|
�s�||
�}
ntj	j|
�r�tj|
tj�r�tjd|
�|
||<|
Sq�WqcWtjd|�dS(sTReturn full path of a executable or None.

    Symbolic links are not followed.
    sfind_executable(%r)tPATHtposixcS`s|S(N((ta((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyt<lambda>bst"ii����tRRtos2s.exes.coms.batsFound executable %ssCould not locate executable %sN(RRR$(tKeyErrorRtdebugtNoneRtenvirontgettdefpathRRtrealpatht
startswithtsplitexttlowertisabsRtpathseptabspathRtislinktisfiletaccesstX_OKtinfotwarn(texeRt_cachetkeytorig_exeR+tsuffixesRtexttextra_suffixestpathstptstf_ext((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyRPsF
		1


'
cC`sBtjd|�i}x$|D]}tjj|�||<qW|S(Ns_preserve_environment(%r)(RR&RR(R)(tnamestenvR((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyt_preserve_environment�s

cK`sAtjd�x-|j�D]\}}|p/dtj|<qWdS(Ns_update_environment(...)R#(RR&titemsRR((RDRtvalue((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyt_update_environment�s
cC`sCt|d�r;y|j�}tSWq?tk
r7tSXntSdS(sT
    Returns True if 'stream' supports the file descriptor and allows fileno().
    tfilenoN(thasattrRItTruetIOErrortFalse(tstreamtr((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyt_supports_fileno�s
R#icK`shtjd|djg|j�D]}d|^q�f�|dkr[tjdk}n|dkrytjdk}ntjj|�}tjjtj	��}t
ddkr�tjjtjjt��}ngtjj
d�r�tjjd�}n@tjjtjd	�}tjj
|�r;tjj|�}n||krhtj|�tjd
|�ntjd|�tt|j���}	t|�z�|r�ttj�r�tjj�dkr�t|d
||�}
nHtjdkr
t|d|d||�}
nt|d|d||�}
Wd||krYtj|�tjd|�nt|	�X|
S(s�
    Return (status,output) of executed command.

    Parameters
    ----------
    command : str
        A concatenated string of executable and arguments.
    execute_in : str
        Before running command ``cd execute_in`` and after ``cd -``.
    use_shell : {bool, None}, optional
        If True, execute ``sh -c command``. Default None (True)
    use_tee : {bool, None}, optional
        If True use tee. Default None (True)


    Returns
    -------
    res : str
        Both stdout and stderr messages.

    Notes
    -----
    On NT, DOS systems the returned status is correct for external commands.
    Wild cards will not work for non-posix systems or when use_shell=0.

    sexec_command(%r,%s)t,s%s=%rRi�Rsexec_command.pyt.isNew cwd: %ssRetaining cwd: %si����texec_command_dirt	use_shelltuse_teeNsRestored cwd to %s(RR&RRFR'RRRR1tgetcwdt__name__tdirnamet__file__R3RtargvtchdirREtlisttkeysRHRPtstdoutRIt_exec_command_pythont_exec_command_posixt
_exec_command(tcommandt
execute_inRTRUt_with_pythonRDtkvtoldcwdtexec_dirtoldenvtst((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyR�sN1!


		
c
K`s�tjd�t|�r1djt|��}n|}t�}d}|r�t�}d}|dkrpd}nd||||f}nt�}d|||f}tjd|�tj|�}	|r�|	r�tj	d	|	�t
|d
||�Sn|dk	rEt|d�}
|
j�}t
|�}	|
j�tj|�nt|d�}
|
j�}|
j�tj|�|dd
kr�|d }n|	|fS(Ns_exec_command_posix(...)t R#is!| tr -cd "\n" | tr "\n" "."; echos&( %s ; echo $? > %s ) 2>&1 | tee %s %ss( %s ; echo $? > %s ) > %s 2>&1sRunning os.system(%r)s&_exec_command_posix failed (status=%s)RTROi����s
(RR&RRR\R
R'RtsystemR7RaR	treadtintR
tremove(
RbRTRURDtcommand_strttmpfiletstsfiletfiltert
command_posixtstatustftstatus_textttext((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyR`�sF
				



cK`s�tjd�t�}t�}t�}t�}t|d�}|jd�|jd�|jd|�|jd�|jd�|jd|�|jd	tj�|jd
|�|jd|�|jd|�|j�d
||f}tj	|�}	|	r"t
d|f��ntj|�t|d�}t
|j��}	|j�tj|�t|d�}|j�}
|j�tj|�|	|
fS(Ns_exec_command_python(...)tws
import os
simport sys
ssys.path.insert(0,%r)
s&from exec_command import exec_command
sdel sys.path[0]
s	cmd = %r
sos.environ = %r
s.s,o = exec_command(cmd, _with_python=0, **%r)
s)f=open(%r,"w")
f.write(str(s))
f.close()
s$f=open(%r,"w")
f.write(o)
f.close()
s%s %ss	%r failedRO(RR&RR
topentwriteRR(R
RktRuntimeErrorRnR	RmRl(RbRSRDt
python_exetcmdfileRqtoutfileRutcmdRtRw((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyR_(s>
				









cC`s(|ddkr$d|kr$d|S|S(NiR"Rjs"%s"((targ((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyt	quote_argPscK`sGtjd�|dkr+tjdk}n|dkrItjdk}nd}|r�tjjdd�}t|�r�|ddjt	|��g}q�|d|g}n%t|�r�|}nt
j|�}ttd�r�tj
}n�tj}t|d�p	|d|d<tjj|d�smtjd	|d�tjdkrmtjdd
g|}d}qmnttj�}ttj�}	tjj}
tjj}|r�tjj�}tj|�}
n|	r�tjj�}tj|�}nt�}t|d�}|r*t�}t|d�}ntjd|jtj|d|f�tjddkr�tjd
kr�i}xytjj�D]\\}}y,|j tj!��||j tj!��<Wq�t"k
r�tjd|�q�Xq�Wn	tj}|d}|st#|�|d<n|
�|�|rEtj$|j�|�n|	r�|rjtj$|j�|�q�tj$|j�|�ny|tj|||�}WnDt%k
r�t&t'��}d}tjj(d||df�nX|
�|�|rtj$|
|�tj)|
�n|	r@tj$||�tj)|�n|j)�t*|d�}|j+�}|j)�tj,|�|r�|j)�t*|d�}|j+�}|j)�tj,|�|r�|r�|r�|d}n||}t-|�q�n|ddkr|d }n|dkr*d}n|r=t-|�n||fS(Ns_exec_command(...)RitSHELLs/bin/shs-cRjtspawnvpesExecutable %s does not existRRtCOMSPECs/CiRxsRunning %s(%s,%r,%r,os.environ)is"ignoring un-encodable env entry %si�s%s: %sROs
i����(RR(.RR&R'RRR(R)RRR\tshlexRRJR�tspawnveRRR3R7RPRR^tstderrtflushRItdupR
RyRWtP_WAITtversion_infoRFtencodetgetfilesystemencodingtUnicodeEncodeErrorR�tdup2t	ExceptiontstrRRzR
R	RlRntprint(RbRTRURDt
using_commandtshRZt
spawn_commandt_so_has_filenot_se_has_filenotso_flushtse_flusht	so_filenotso_dupt	se_filenotse_dupR~tfoutterrfiletferrtencoded_environtktvtargv0RtterrmessRw((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyRaUs�
!
				"	&
	

"









	
cK`sLt�}td�}|dk}|r�tjd�t|d�\}}t|ddd�\}}dtjd<t|d	�\}}t|d	dd
�\}}t|d	�\}}ntd�\}}td|�\}}td
|�\}}td|�\}}td|�\}}td|�\}}td�dS(Ntechos7Using cygwin echo in win32 environment is not supporteds. -c "import os;print os.environ.get('AAA','')"s+ -c "import os;print os.environ.get('AAA')"tAAAtTeretHitBBBs. -c "import os;print os.environ.get('BBB','')"tHeysecho path=%path%s1%s -c "import sys;sys.stderr.write(sys.platform)"s%s -c "raise 'Ignore me.'"sT%s -c "import sys;sys.stderr.write('0');sys.stderr.write('1');sys.stderr.write('2')"s%s -c "import sys;sys.exit(15)"s%s -c "print 'Heipa'"tok(RRRR7RRR(R�(tkwsRR�tusing_cygwin_echoRAto((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyttest_nt�s8	

cK`sMtd|�\}}td|�\}}tddd|�\}}td|�\}}dtjd<td|�\}}tddd	|�\}}td|�\}}td
|�\}}td|�\}}td|�\}}td
|�\}}td|�\}}td|�\}}td|�\}}td�dS(Ns
echo Hellos	echo $AAAsecho "$AAA"R�R�R�R�secho "$BBB"R�tthis_is_not_a_commandsecho path=$PATHs3python -c "import sys,os;sys.stderr.write(os.name)"spython -c "raise 'Ignore me.'"sXpython -c "import sys;sys.stderr.write('0');sys.stderr.write('1');sys.stderr.write('2')"s#python -c "import sys;sys.exit(15)"spython -c "print 'Heipa'"R�(RRR(R�(R�RAR�((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyt
test_posix-s 
cK`s�t�}t�}tjj|�}tjj|�}t|d�}|jd�|j�t	d||f|�\}}t	d||fd||�\}}tj
|�td�dS(NRxtHellos:%s -c "print 'Ignore the following IOError:',open(%r,'r')"s!%s -c "print open(%r,'r').read()"RcR�(RR
RRtbasenameRXRyRzR
RRnR�(R�RRpRttmpdirRuRAR�((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyttest_execute_in]s		


cK`s)tddg|�\}}td�dS(NtsvnRtssvn ok(RR�(R�RAR�((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyttest_svnoscK`s;tjdkr7tddg|�\}}td�ndS(NRtcls/Vscl ok(RRRR�(R�RAR�((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyttest_cltsRRRsexec_command tests for t__main__RU(RR('t__doc__t
__future__RRRt__all__RRR�tnumpy.distutils.misc_utilRRtnumpy.distutilsRtnumpy.distutils.compatRtnumpy.compatR	R
RR'RRERHRPRR`R_R�RaR�R�R�R�R�RttesttNotImplementedErrorRW(((sO/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/exec_command.pyt<module>3sN			3			
	W4'	�	L	0					






Zerion Mini Shell 1.0