Current File : //opt/imh-python/lib/python2.7/site-packages/sh.pyo
�
�)�Tc@sJdZdZdZddlZdej�j�krIede��nddlZejddkZ	ddl
Z
ddlZddlZdd	l
m
ZddlZdd
lmZddlmZddlZddlmZdd
lmZe�pdZe	r^ddlmZddlmZddlmZm Z e!e"d�r[d�Z#nn6ddlmZddlm$ZddlmZm Z ej�dkZ%ej&j'ej&j(e)��Z*dZ+ddl,Z,ddl-Z-ddl.Z.ddl/Z/ddl0Z0ddl1Z1ddl2Z2ddl3Z3ddl4Z4ddl5Z5ddl6Z6ddl7Z7ddl8m9Z9ddl:Z:ddl;Z;d�Z<e	r�e=Z>e?Z@e?ZAneBeCe@���ZDd�ZEdeFfd��YZGdeGfd��YZHdeFfd��YZIe0jJe0jKe0jLe0jMe0jNe0jOe0jPe0jQe0jRe0jSe0jTfZUd eVfd!��YZWejXd"�ZYiZZd#�Z[d$�Z\d%�Z]d&�Z^d'�Z
d(e_fd)��YZ`d*�Zad+e_fd,��YZbd-�Zcd.e_fd/��YZdd0�Zed1�Zfd2�Zgd3�Zhd4e_fd5��YZid6eFfd7��YZjd8eFfd9��YZkd:�Zld;�Zmd<�Znd=�Zod>�Zpd?�Zqd@�ZrdAe_fdB��YZsdC�ZtdD�ZudE�ZvdF�ZwdG�ZxdHe_fdI��YZydJe_fdK��YZzedL��Z{edM��Z|dNe}fdO��YZ~dP�ZdQefdR��YZ�e�dSkr&yej�j�dT�Z�Wn
e�Z�nXe�dUkr
ddl�Z�dV�Z�dWdXdYdZd[d\fZ�d]d^fZ�x,e�D]$Zxe�D]Z�e�e�e�q�Wq�Wne~e���Z�ee��n ej�e�Z�e�e��ej�e�<dS(_s
http://amoffat.github.io/sh/
s1.11shttps://github.com/amoffat/shi����Ntwindowss�sh %s is currently only supported on linux and osx. please install pbs 0.110 (http://pypi.python.org/pypi/pbs) for windows support.ii(tglob(t
ModuleType(tpartial(tcontextmanager(tgetpreferredencodingsUTF-8(tStringIO(tBytesIO(tQueuetEmptytcallablecCs
t|d�S(Nt__call__(thasattr(tob((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR
@s(t
OutputTypetDarwintsh(tdequecCstjdj�dd�dS(Ns�
with contexts are deprecated because they are not thread safe.  they will be removed in the next version.  use subcommands instead http://amoffat.github.io/sh/#sub-commands. see https://github.com/amoffat/sh/issues/195
t
stackleveli(twarningstwarntstrip(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytwith_context_warning_scCs�d}trct|t�rq�t|�}yt|t�}Wq�tk
r_t||�}q�Xn_yt|t�}Wntk
r�t|�}nXy|jt�}Wn|j|�}nX|S(s� takes anything and attempts to return a py2 string or py3 bytes.  this
    is typically used when creating command + arguments to be executed via
    os.exec* tutf8(	tIS_PY3t
isinstancetbyteststrtDEFAULT_ENCODINGtUnicodeEncodeErrortunicodet	TypeErrortencode(tstfallback_encoding((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytencode_to_py3bytes_or_py2strrs$

tErrorReturnCodecBseZdZdZd�ZRS(s� base class for all exceptions as a result of a command's exit status
    being deemed an error.  this base class is dynamically subclassed into
    derived classes with the format: ErrorReturnCode_NNN where NNN is the exit
    code number.  the reason for this is it reduces boiler plate code when
    testing error return codes:
    
        try:
            some_cmd()
        except ErrorReturnCode_12:
            print("couldn't do X")
            
    vs:
        try:
            some_cmd()
        except ErrorReturnCode as e:
            if e.exit_code == 12:
                print("couldn't do X")
    
    it's not much of a savings, but i believe it makes the code easier to read i�c	Cs||_||_||_|jdkr3d}nF|j|j }t|j�t|�}|ry|d|j�7}n|jdkr�d}nF|j|j }t|j�t|�}|r�|d|j�7}nd||jtd�|jtd�f}t	t
|�j|�dS(Ns<redirected>s"... (%d more, please see e.stdout)s"... (%d more, please see e.stderr)s'

  RAN: %r

  STDOUT:
%s

  STDERR:
%streplace(tfull_cmdtstdouttstderrtNonettruncate_captlenR tdecodeRtsuperR$t__init__(	tselfR&R'R(t
exc_stdoutt	out_deltat
exc_stderrt	err_deltatmsg((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.�s&					(t__name__t
__module__t__doc__R*R.(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR$�stSignalExceptioncBseZRS((R5R6(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR8�stTimeoutExceptioncBseZdZd�ZRS(sf the exception thrown when a command is killed because a specified
    timeout (via _timeout) was hit cCs ||_tt|�j�dS(N(t	exit_codeR-t	ExceptionR.(R/R:((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.�s	(R5R6R7R.(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR9�stCommandNotFoundcBseZRS((R5R6(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR<�ss0(ErrorReturnCode|SignalException)_((\d+)|SIG\w+)cCs�d}yt|SWn�tk
r�tj|�}|r�|jd�}|jd�}|dkr�yt|�}Wq�tk
r�tt	|�}q�Xnt|�}t
|�}q�nX|S(s takes an exception name, like:

        ErrorReturnCode_1
        SignalException_9
        SignalException_SIGHUP

    and returns the corresponding exception.  this is primarily used for
    importing exceptions from sh into user code, for instance, to capture those
    exceptions iiR8N(R)trc_exc_cachetKeyErrortrc_exc_regextmatchtgrouptintt
ValueErrortgetattrtsignalt
get_rc_exc(tnametexctmtbasetrc_or_sig_nametrc((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytget_exc_from_name�s 

cCs�yt|�}Wn!tk
r3tt|�}nXyt|SWntk
rSnX|dkrsd|}t}ndt|�}t}t	||fi|d6�}|t|<|S(sO takes a exit code, signal number, or signal name, and produces an
    exception that corresponds to that return code.  positive return codes yield
    ErrorReturnCode exception, negative return codes yield SignalException

    we also cache the generated exception so that only one signal of that type
    exists, preserving identity isErrorReturnCode_%dsSignalException_%dR:(
RBRCRDRER=R>R$tabsR8ttype(RKRLRGRJRH((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRFs 


	
cCs�d�}tjj|�\}}|r:||�r�|Sn\dtjkrMdSxFtjdjtj�D]+}tjj||�}||�rg|SqgWdS(NcSsCtjj|�oBtj|tj�oBtjjtjj|��S(N(tostpathtexiststaccesstX_OKtisfiletrealpath(tfpath((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytis_exe-stPATH(RPRQtsplittenvironR)tpathseptjoin(tprogramRXRWtfnameRQtexe_file((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytwhich,s	 cCsJt|�}|sFd|kr9t|jdd��}n|sFdSn|S(Nt_t-(RaR%R)(R^RQ((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytresolve_program@scCst|�p|S(N(t
original_glob(targ((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRUstLoggercBsPeZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	sO provides a memory-inexpensive logger.  a gotcha about python's builtin
    logger is that logger objects are never garbage collected.  if you create a
    thousand loggers with unique names, they'll sit there in memory until your
    script is done.  with sh, it's easy to create loggers with unique names if
    we want our loggers to include our command arguments.  for example, these
    are all unique loggers:
        
            ls -l
            ls -l /tmp
            ls /tmp

    so instead of creating unique loggers, and without sacrificing logging
    output, we use this class, which maintains as part of its state, the logging
    "context", which will be the very unique name.  this allows us to get a
    logger with a very general name, eg: "command", and have a unique name
    appended to it via the context, eg: "ls -l /tmp" cCsM||_|r$|jdd�}n||_tjdt|f�|_dS(Nt%s%%s%s.%s(RGR%tcontexttloggingt	getLoggertSH_LOGGER_NAMEtlog(R/RGRi((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.ks
		cGs'|jrd|j|f}n||S(Ns%s: %s(Ri(R/R4targs((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt_format_msgrs	cCs5|jd|}|jd|}t||�}|S(Nt.(RGRiRg(R/RGRitnew_nametnew_contexttl((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt	get_childwscGs |jj|j||��dS(N(RmtinfoRo(R/R4Rn((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRu}scGs |jj|j||��dS(N(RmtdebugRo(R/R4Rn((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRv�scGs |jj|j||��dS(N(RmterrorRo(R/R4Rn((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRw�scGs |jj|j||��dS(N(Rmt	exceptionRo(R/R4Rn((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRx�sN(R5R6R7R)R.RoRtRuRvRwRx(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRgZs					cCs7t|�|kr3d|| t|�|f}n|S(Ns%s...(%d more)(R+(R!tmax_len((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytfriendly_truncate�s!tRunningCommandcBs�eZdZd�Zd�Zd�Zed��Zed��Zed��Z	ed��Z
d�Zd	�Zd
�Z
d�ZeZd�Zd
�Zd�Zd�ZdZd�Zd�Zd�Zd�Zd�Zd�ZRS(s� this represents an executing Command object.  it is returned as the
    result of __call__() being executed on a Command instance.  this creates a
    reference to a OProc instance, which is a low-level wrapper around the
    process that was exec'd

    this is the class that gets manipulated the most by user code, and so it
    implements various convenience methods and logical mechanisms for the
    underlying process.  for example, if a user tries to access a
    backgrounded-process's stdout/err, the RunningCommand object is smart enough
    to know to wait() on the process to finish first.  and when the process
    finishes, RunningCommand is smart enough to translate exit codes to
    exceptions. c
Cs(tr:djg|D]}|jtd�^q�|_ndj|�|_t|jd�}tt|�d�}d||f}	td|	�|_||_	||_
d|_t
|_t}
t}|dr�t
}tjj|�n|ds|ds|d	rt
}
n|d
r"t
}
n|dr8tj}ntj}|ddksa|dtkrmtj}n|dd
kr�tj}n|d	dks�|d	tkr�tj}n|d	d
kr�tj}n|r$|jjd�t|j|||||j	|�|_|
r$|j�q$ndS(Nt tignoreis<Command %r call_args %s>tcommandtwithtpipedtitertiter_noblocktbgt
err_to_outtoutterrsstarting process(RR]R,RtranRzRRgRmt	call_argstcmdR)tprocesstFalset_process_completedtTruetCommandt_prepend_stacktappendtOProctSTDOUTtSTDERRRutwait(
R/R�R�tstdinR'R(Rftfriendly_cmdtfriendly_call_argst
logger_strtshould_waitt
spawn_processtpipe((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.�sL4
				
	
	
	  cCsr|jsnt|_|jj�}|jjr=t|��n
|j|�|jdrn|jd|�qnn|S(Ntdone(R�R�R�R�t	timed_outR9thandle_command_exit_codeR�(R/R:((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s		

cCs`||jdkr\|dks,|tkr\t|�}||j|jj|jj��ndS(s� here we determine if we had an exception, or an error code that we
        weren't expecting to see.  if we did, we create and raise an exception
        tok_codeiN(R�t#SIGNALS_THAT_SHOULD_THROW_EXCEPTIONRFR�R�R'R((R/tcodeRH((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s#	cCs|j�|jjS(N(R�R�R'(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR's
cCs|j�|jjS(N(R�R�R((R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR(
s
cCs|j�|jjS(N(R�R�R:(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR:s
cCs
|jjS(N(R�tpid(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�scCstt|��S(N(R+R(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__len__scCst�dS(s� we don't actually do anything here because anything that should have
        been done would have been done in the Command.__call__ call.
        essentially all that has to happen is the comand be pushed on the
        prepend stack. N(R(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt	__enter__scCs|S(N((R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__iter__%scCs�x�tr�y|jjjtd�}Wn%tk
rL|jdr�tjSqX|dkro|j	�t
��ny"|j|jd|jd�SWqtk
r�|SXqWdS(s4 allow us to iterate over the output of our command g����MbP?R�tencodingt
decode_errorsN(
R�R�t_pipe_queuetgetR	R�terrnotEWOULDBLOCKR)R�t
StopIterationR,tUnicodeDecodeError(R/tchunk((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytnext(s	



cCs*|jdr&tjr&tjj�ndS(NR(R�R�R�tpop(R/ttyptvaluet	traceback((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__exit__@scCs.tr|j�St|�j|jd�SdS(sY in python3, should return unicode.  in python2, should return a
        string of bytes R�N(Rt__unicode__RR R�(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__str__Ds
cCsK|jr3|jr3|jj|jd|jd�Str=dStd�SdS(sj a magic method defined for python2.  calling unicode() on a
        RunningCommand object will call this R�R�tN(R�R'R,R�RR(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�LscCst|�t|�kS(N(R(R/tother((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__eq__WscCs|t|�kS(N(R(R/titem((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__contains__[scCsW|dkr.|jr%t|j|�St�n|tkrMtt|�|�St�dS(NREt	terminatetkill(ssignals	terminateskill(R�RDtAttributeErrort_unicode_methodsR(R/tp((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__getattr__^s		cCsOyt|�SWn:tk
rJ|jr@|jr@t|j�Sntd�SXdS(sY in python3, should return unicode.  in python2, should return a
        string of bytes R�N(RR�R�R'trepr(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__repr__qs
		cCstt|�j��S(N(tlongRR(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__long__|scCstt|�j��S(N(tfloatRR(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt	__float__scCstt|�j��S(N(RBRR(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__int__�sN(R5R6R7R.R�R�tpropertyR'R(R:R�R�R�R�R�t__next__R�R�R�R�R)t__hash__R�R�R�R�R�R�(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR{�s0	K															cCs7|o6t|�o6t|d�o6t|ttf�S(Ntwrite(R
RRt	cStringIOR(R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytoutput_redirect_is_filename�s
R�cBs�eZdZgZied6ed6d9d6d9d6d9d6d9d6dd6d	d
6d	d6dd:d6d9d6d9d6d9d6d9d6dd6d9d6dd6ed6ed6ed6dd6dd6ej	d6ed6ed 6ed!6d9d"6d9d#6d;d&6Z
d<d=d>d?fZed+��Z
d,�Zd-�Zeid.��Zed/�Zd0�Zd1�Zd2�Zd3�Zd9Zd4�Zd5�Zd6�Zd7�Zd8�ZRS(@s� represents an un-run system program, like "ls" or "cd".  because it
    represents the program itself (and not a running instance of it), it should
    hold very little state.  in fact, the only state it does hold is baked
    arguments.
    
    when a Command object is called, the result that is returned is a
    RunningCommand object, which represents the Command put into an execution
    state. R�RtinR�R�R�it
in_bufsizeitout_bufsizeterr_bufsizeiiitinternal_bufsizetenvR�R�R�R�tcwdt=tlong_septtty_inttty_outR�tstrictR�ttimeoutttimeout_signaltno_outtno_errtno_pipetteeR�iiPttty_sizes"Stderr is already being redirecteds3You cannot iterate when this command is being pipeds;Using a pipe doesn't make sense if you've disabled the pipes4You cannot iterate over output if there is no outputcKsIt|�}|s!t|��n||�}|rE|j|�}n|S(N(RdR<tbake(tclsR^tdefault_kwargsRQR�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt_createscCs^t|�}|s!t|��nt|�|_t|_g|_i|_t|�|_	dS(N(
RaR<R#t_pathR�t_partialt_partial_baked_argst_partial_call_argsRR5(R/RQtfound((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.s			cCsmttj|�}|jd�r+||�S|dkrA|d�S|jd�r]|d }n|d�|�S(NRbR�i����(Rtobjectt__getattribute__t
startswithtendswith(R/RGRD((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR� s


c	Cs�|j�}i}xhtjj�D]W\}}d|}||kr\||||<||=q"||kr"||||<q"q"Wt|j��}xQtjD]F}t|�}|j�}|j	|�r�t
d||f��q�q�W||fS(NRbs Invalid special arguments %r: %s(tcopyR�t
_call_argstitemstsettkeyst_incompatible_call_argstlistR�t
issupersetR(	tkwargstto_overrideR�tpargtdefaulttkeyts1RnRw((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt_extract_call_args.s 

cCs�g}x�|j�D]�\}}t|�dkr||tk	r�|jtd|��|tk	ry|jt|��qyq�q|s�|jdd�}n|tkr�|jtd|��q|tkr�qtd|||f�}|j|�qW|S(NiRcRbs--s--%s%s%s(R�R+R�R�R#R�R%(R/tkeywordstseptrawt	processedtktvRf((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt_aggregate_keywordsGs cCs�g}x�|D]�}t|ttf�rr|sKtjd|jdd�nxe|D]}|jt|��qRWq
t|t�r�||j	||dt
�7}q
|jt|��q
W||j	||�7}|S(NsbEmpty list passed as an argument to %r. If you're using glob.glob(), please use sh.glob() instead.RiR(RR�ttupleRRR�R�R#tdictRR�(R/RnR�R�tprocessed_argsRftsub_arg((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt
_compile_argsas

c	Os�t|j�}t|_|j|�\}}|}xRtjj�D]A\}}y|||krl||=nWqCtk
r�qCqCXqCW|jj	|j�|jj	|�|j
j|j
�|jd|jd�}|j
j|j
|||��|S(NR�(R�R�R�R�R�R�R�R>R�tupdateR�textendR�R	(	R/RnR�tfnR�tpruned_call_argsRRR�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�xs 	
cCs'tr|j�S|j�jt�SdS(sY in python3, should return unicode.  in python2, should return a
        string of bytes N(RR�R R(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s
cCs)yt|�t|�kSWntSXdS(N(RR�(R/R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��scCsdt|�S(sY in python3, should return unicode.  in python2, should return a
        string of bytes s<Command %r>(R(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��scCsCdjd�|jD��}|r/d|}n|jjt�|S(sY a magic method defined for python2.  calling unicode() on a
        self will call this R|css|]}|jt�VqdS(N(R,R(t.0R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pys	<genexpr>�s(R]R�R�R,R(R/t
baked_args((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s
cCst�|dt�dS(Nt_with(RR�(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��scCstjj�dS(N(R�R�R�(R/R�R�R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��scOs/|j�}t|�}g}tjj�}xR|jD]G}|jj�}y|d=WnnX|j|�|j|j�q7W|j	|j
�|j||j�\}}|j|�t
|ddd�s�|dg|d<n|dr�t|d<n|d}|r�|jd�}	t|	t�rq|	jdrCt|d<n|	jdd	krb|	j}q�|	jj}q�|jd|	�n|j|||d
�}
|j|
}|}|j|�|d}
t|
�r�tt|
�d�}
n|d
}t|�rtt|�d�}nt||||
|�S(NRR�R�R�R�R�iR�tdirectR�R�twbR�(R�R�R�R�R�R�R
RR�R�R�R�R�RDR)R�R�RR{R�R�tinsertR	R�R�topenR(R/RnR�R�R�tprependt
pcall_argst
tmp_call_argsR�t	first_argRt
split_argst
final_argsR'R(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�sP










Ni(iiP(serrs
err_to_outs"Stderr is already being redirected(spipedsiters3You cannot iterate when this command is being piped(spipedR�s;Using a pipe doesn't make sense if you've disabled the pipe(R�siters4You cannot iterate over output if there is no output(R5R6R7R�R�R)R�RREtSIGKILLR�R�tclassmethodR�R.R�tstaticmethodR�RR	R�R�R�R�R�R�R�R�R(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��sl

	

											cGs/tjd|d|�}t|_|j�|S(NttargetRn(t	threadingtThreadR�tdaemontstart(RRntthrd((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt_start_daemon_threads	
cCsP|\}}ttdd�}tjd||dd�}tj|||�dS(sU set the terminal size of a tty file descriptor.  borrowed logic
    from pexpect.py t
TIOCSWINSZigt�tHHHHiN(RDttermioststructtpacktfcntltioctl(tfdt	rows_colstrowstcolsR%R!((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt
setwinsize	scs8d}d}�}t�t�r<t�j�}�j}ntj|�rld}ttj|�j�}nKtj|�r�ttj|�j�}n!d}ttj|j	�j�}|||}d�|dkr�d�n|dkr�|j
f�n'|dkr"|j
tj|�f�n��fd�}|S(s` here we're constructing a closure for our streamreader callback.  this
    is used in the case that we pass a callback into _out or _err, meaning we
    want to our callback to handle each bit of output

    we construct the closure based on how many arguments it takes.  the reason
    for this is to make it as easy as possible for people to use, without
    limiting them.  a new user will assume the callback takes 1 argument (the
    data).  as they get more advanced, they may want to terminate the process,
    or pass some stdin back, and will realize that they can pass a callback of
    more args iiiics?�}t|�dkr2�d�d�f}n�||�S(Niii(R+(R�Rn(thandlerthandler_args(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRLs(((
RRR+Rntfunctinspecttismethodt
getargspect
isfunctionRR�tweakreftref(R�R1timplied_argtpartial_argsthandler_to_inspecttnum_argstnet_argsR((R1R2s1/opt/imh-python/lib/python2.7/site-packages/sh.pytconstruct_streamreader_callbacks.	cCsItj|�rtj|�Stj|�r9tj|�Std��dS(s= this should only ever be called once for each child process sUnknown child exit status!N(RPtWIFSIGNALEDtWTERMSIGt	WIFEXITEDtWEXITSTATUStRuntimeError(R:((s1/opt/imh-python/lib/python2.7/site-packages/sh.pythandle_process_exit_codeXs

R�cBs�eZdZddfZdZdZd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Ze
d��Ze
d
��Zd�Zd�Zd�Zd�Zd�ZRS(s$ this class is instantiated by RunningCommand for a command to be exec'd.
    it handles all the nasty business involved with correctly setting up the
    input/output to the child process.  it gets its name for subprocess.Popen
    (process open) but we're calling ours OProc (open process) iiPi����i����cCs<||_|jddkr,t|jd<n|jdoC|jd|_|jr�tj�\|_|_|j|_|j|_|j|_	|j|_
n�t|t�r�|j|_d|_n@|jdr�tj�\|_|_ntj�\|_|_|jdr,tj�\|_|_ntj�\|_|_|tjk	rntj�\|_	|_
n|jd}|dk	r�tjj|�r�tj|�ntj�}	|	r�tj�ntj�|_|jdkrz|jdtkrtjtjtj�ntr,tjd�ntj �|jdrVt!j"|j�n|jrrtj#|j�n|js�tj#|j�|tjk	r�tj#|j	�q�n|r�tj|�ntj$|jd�tj$|jd	�|tjkrtj$|jd
�ntj$|j
d
�t%j&t%j'�d}
tj(d|
�|jdr�tj)tj*d	�tj+�}tj#|�n|jdr�t,d	|jd�n|jd
dkr�tj-|d|�ntj.|d||jd
�Wdtj/d�Xn2|	rtj0�nt|_1tj�|_2||_3d|_4|pOt5�|_6t5�|_7t8j9�|_:t;d|jd�|_<t;d|jd�|_=|jdr�t,|j|jd�n|j>dt?|��|_@tj#|j�|js2tj#|j�|tjk	r2tj#|j
�q2n|j@jAd�|jdr�tBjC|j�}|dctBjDM<tBjE|jtBjF|�nd|_Gt|j6t�s�tH|j@j>dd�|j|j6|jd|jd|jd�|_Gnd}
|tjkr&|jdr&|j7}
n|jdoV|jdtdfkpV|dk}d|_I|jddkr�tJ|�r�tK||�}ntL|j@j>dd�|j||j<|jd|jd|jd|
d |�|_In|tjks|jrd|_Mn�d}|tjNkr=|jdr=|j7}n|jd!og|jdd&kpg|dk}tJ|�r�tK||�}ntLtOd�|j	||j=|jd#|jd|jd|d |�|_Md|_P|jGrtQ|jR|jG�|_PntQ|jS|jI|jM|jd$|j2|jd%�|_TdS('s]
            cmd is the full string that will be exec'd.  it includes the program
            name and all its arguments

            stdin, stdout, stderr are what the child will use for standard
            input/output/err

            call_args is a mapping of all the special keyword arguments to apply
            to the child process
        R�RR�R�R�iR�g{�G�z�?iiiR�R�Ni�tmaxlenR�R�sstarted procesststreamwriterR�R�R�R�R�R�R�tstreamreaderR'R�R�t	save_dataR�R�R�R�R�(serr(UR�R�t_single_ttytptytopenptyt	_stdin_fdt_slave_stdin_fdt
_stdout_fdt_slave_stdout_fdt
_stderr_fdt_slave_stderr_fdRR�R)RPR�R�RQRRtchdirtgct	isenabledtdisabletforkR�R�REtSIGHUPtSIG_IGNtIS_OSXttimetsleeptsetsidtttytsetrawtclosetdup2tresourcet	getrlimitt
RLIMIT_NOFILEt
closerangeRtttynametO_RDWRR0texecvtexecvet_exittenableR�tstartedR�R:RR�R�RtLockt
_wait_lockRt_stdoutt_stderrRtR�RmRvR't	tcgetattrtECHOt	tcsetattrtTCSANOWt
_stdin_streamtStreamWritert_stdout_streamR
R?tStreamReadert_stderr_streamR�Rgt
_input_threadR$tinput_threadt
output_threadt_output_thread(R/t
parent_logR�R�R'R(R�R�R�t
gc_enabledtmax_fdttmp_fdtattrtstdout_pipetsave_stdouttstderr_pipetsave_stderr((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.rs		






		

"

			
	
	

%	

				cCsd|j|jd fS(Ns<Process %d %r>i�(R�R�(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��scCs|jjj|�dS(N(Rutstream_bufferertchange_buffering(R/tbuf((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytchange_in_bufsize�scCs|jjj|�dS(N(RwR�R�(R/R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytchange_out_bufsize�scCs|jjj|�dS(N(RyR�R�(R/R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytchange_err_bufsize�scCsMt}x6|r>|j�r>|jjd|�|j�}q	W|j�dS(s� this is run in a separate thread.  it writes into our process's
        stdin (a streamwriter) and waits the process to end AND everything that
        can be written to be written s%r ready for more inputN(R�tis_aliveRmRvR�R`(R/R�R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR{�s
cCs{g}g}|dk	r5|j|�|j|�n|dk	r^|j|�|j|�nx�|r0tj|g|d�\}}	}
xC|D];}|jjd|�|j�}|r�|j|�q�q�Wx|
D]}q�W|ratj�}
|
||kr-|jjd�t|_	|j
|�q-qaqaWx|j�rPtjd�q4W|rd|j
�n|rw|j
�ndS(s� this function is run in a separate thread.  it reads from the
        process's stdout stream (a streamreader), and waits for it to claim that
        its done g�������?s%r ready to be read fromswe've been running too longg����MbP?N(R)R�tselectRmRvtreadtremoveR[R�R�RER�R\R`(R/R'R(R�Rlttimeout_exctreadersterrorstoutputstinputsR�tstreamR�tnow((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR|�s:

	!

	
cCs dj|jd�j|j�S(NR�R�(R R�R]Ro(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR'�scCs dj|jd�j|j�S(NR�R�(R R�R]Rp(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR(�scCsB|jjd|�ytj|j|�Wntk
r=nXdS(Nssending signal %d(RmRvRPR�R�tOSError(R/tsig((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRE�s

cCs$|jjd�|jtj�dS(Ntkilling(RmRvRER(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�scCs$|jjd�|jtj�dS(Ntterminating(RmRvREtSIGTERM(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�scCs�|jdk	rtS|jjt�}|sB|jdk	r>tStSzayDtj|jtj	�\}}||jkr�t
|�|_tSWntk
r�tSXtSWd|jj�XdS(s� polls if our child process has completed, without blocking.  this
        method has side-effects, such as setting our exit_code, if we happen to
        see our child exit while this is running N(
R:R)R�RntacquireR�RPtwaitpidR�tWNOHANGRER�trelease(R/tacquiredR�R:((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�s"
cCs�|jjd�|j��|jjd�|jdkrv|jjd�tj|jd�\}}t|�|_n|jjd|j�|j	r�|j	j
�n|jj
�|jSWdQXdS(s: waits for the process to complete, handles the exit code s*acquiring wait lock to wait for completions
got wait locks!exit code not set, waiting on pidis+exit code already set (%d), no need to waitN(RmRvRnR:R)RPR�R�RERzR]R}(R/R�R:((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�6s
	
(R5R6R7t_default_window_sizeR�R�R.R�R�R�R�R{R|R�R'R(RER�R�R�R�(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�fs&	�'						@				+tDoneReadingForevercBseZRS((R5R6(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�TstNotYetReadyToReadcBseZRS((R5R6(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�UscCs�d}t|t�r*d}t|�}n�t|�rKd}t|�}n`t|d�rod}t|�}n<t|t�r�d}t	|�}nd}t
t|��}||fS(s given some kind of input object, return a function that knows how to
    read chunks of that input object.
    
    each reader function should return a chunk and raise a DoneReadingForever
    exception, or return None, when there's no more data to read

    NOTE: the function returned does not need to care much about the requested
    buffering type (eg, unbuffered vs newline-buffered).  the StreamBufferer
    will take care of that.  these functions just need to return a
    reasonably-sized chunk of data. tqueueR
R�sfile descriptortstringsgeneral iterableN(R)RRtget_queue_chunk_readerR
tget_callable_chunk_readerRtget_file_chunk_readert
basestringtget_iter_string_readertget_iter_chunk_readerR�(t	input_objt	get_chunktlog_msg((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytdetermine_how_to_read_inputXs cs�fd�}|S(NcsIy�jtd�}Wntk
r/t�nX|dkrEt�n|S(Ng{�G�z�?(R�R�R	R�R)R�(R�(R�(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�s

	((R�R((R�s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�scs�fd�}|S(Ncsy��SWn
t�nXdS(N(R�((R�(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�s((R�R((R�s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��scs;d���fd�tdt����D�}t|�S(s- return an iterator that returns a chunk of a string every time it is
    called.  notice that even though bufsize_type might be line buffered, we're
    not doing any line buffering here.  that's because our StreamBufferer
    handles all buffering.  we just need to return a reasonable-sized chunk. ic3s |]}�||�!VqdS(N((Rti(tbufsizeR�(s1/opt/imh-python/lib/python2.7/site-packages/sh.pys	<genexpr>�si(trangeR+R�(R�titer_str((R�R�s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s+cs�fd�}|S(NcsGy)tr�j�}n�j�}|SWntk
rBt�nXdS(N(RR�R�R�R�(R�(R�(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�s
((R�R((R�s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s	csd���fd�}|S(Nics&�j��}|st�n|SdS(N(R�R�(R�(R�R�(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�s	((R�R((R�R�s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��scCs4|dkrd}n|dkr*d}n|}|S(s for a given bufsize type, return the actual bufsize we will read.
    notice that although 1 means "newline-buffered", we're reading a chunk size
    of 1024.  this is because we have to read something.  we let a
    StreamBufferer instance handle splitting our chunk on newlines iii((tbf_typeR�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytbufsize_type_to_bufsize�s		RvcBs2eZdZd�Zd�Zd�Zd�ZRS(s� StreamWriter reads from some input (the stdin param) and writes to a fd
    (the stream param).  the stdin may be a Queue, a callable, something with
    the "read" method, a string, or an iterable cCsn||_||_||_||_||_t||j�|_t|�\|_}|jj	d|�dS(Nsparsed stdin as a %s(
R�R�RmR�R�tStreamBuffererR�R�R�Rv(R/RmR�R�tbufsize_typeR�R�R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.�s					cCs|jS(sR defining this allows us to do select.select on an instance of this
        class (R�(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytfileno�scCs~y%|j�}|d
kr$t�nWn�tk
r�|jjd�|jr�y!tj|j�dtj	}Wnt
d�j�}nXtj
|j|�ntStk
r�|jjd�tSXtr�t|d�r�|j|j�}nx�|jj|�D]r}|jjdt|�|d �|jjd�ytj
|j|�Wqtk
ru|jjd	�tSXqWd
S(s� attempt to get a chunk of data to write to our child process's
        stdin, then write it.  the return value answers the questions "are we
        done writing forever?" sdone readingiisreceived no dataR sgot chunk size %d: %riswriting chunk to processsOSError writing stdin chunkN(R�R)R�RmRvR�R'RqR�tVEOFtchrR RPR�R�R�R�RRR�R�R�R+R�(R/R�tchart
proc_chunk((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s6

	!

cCs�|jjd�|jj�}|jjdt|�|d �yL|r^tj|j|�n|js�|jjd�tj	|j�nWnt
k
r�nXdS(Nsclosing, but flushing firstsgot chunk size %d to flush: %ris$we used a TTY, so closing the stream(RmRvR�tflushR+RPR�R�R�R`R�(R/R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR`s 	
(R5R6R7R.R�R�R`(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRv�s
			.cCs�t|�r't|||�\}}n�t|t�rKt|�\}}n`t|t�rut|||�\}}n6t|d�r�t|�\}}nd�}d�}||fS(NR�cSstS(N(R�(R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt<lambda>/scSsdS(N(R)(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�0s(	R
tget_callback_chunk_consumerRR�tget_cstringio_chunk_consumerRtget_stringio_chunk_consumerRtget_file_chunk_consumer(R1R�R�R�tfinish((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytdetermine_how_to_feed_output#s				cs(�fd�}�fd�}||fS(Ncs�j|��j�tS(N(R�R�R�(R�(R1(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�6s

cs t�d�r�j�ndS(NR�(RR�((R1(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�=s((R1R�R�((R1s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�5scs(���fd�}d�}||fS(Ncs4y|j���}Wntk
r)nX�|�S(N(R,R�(R�(R�R�R1(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�Ds

cSsdS(N((((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�Ms((R1R�R�R�R�((R�R�R1s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�Cs		cs"�fd�}d�}||fS(Ncs�j|�tS(N(R�R�(R�(R1(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�Ss
cSsdS(N((((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�Ws((R1R�R�((R1s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�Rs	cs(���fd�}d�}||fS(Ncs�j|j����tS(N(R�R,R�(R�(R�R�R1(s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�^scSsdS(N((((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�bs((R1R�R�R�R�((R�R�R1s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�]s	RxcBsAeZdZded�Zd�Zd�Zd�Zd�Z	RS(sV reads from some output (the stream) and sends what it just read to the
    handler.  c

Cs�||_||_|	|_||_||_d|_|rQtj|�|_n||_	t
||j|j�|_t|�|_
t|||�\|_|_t|_dS(N(R�tbufferRIR�R�R)t
pipe_queueR8R9RmR�R�R�R�R�t
process_chunktfinish_chunk_processorR�tshould_quit(
R/RmR�R1R�R�R�R�R�RI((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.ks							cCs|jS(sR defining this allows us to do select.select on an instance of this
        class (R�(R/((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��scCs�|jj�}|jjdt|�|d �|rE|j|�n|j�|jrw|jrw|j�j	d�nytj|j
�Wntk
r�nXdS(Nsgot chunk size %d to flush: %ri(R�R�RmRvR+twrite_chunkR�R�RItputR)RPR`R�R�(R/R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR`�s 

cCst|js|j|�|_n|jrp|jj|�|jrp|jjd|d �|j�j|�qpndS(Nsputting chunk onto pipe: %ri(	R�R�RIR�R�R�RmRvR�(R/R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s			cCs�ytj|j|j�}Wn*tk
rH}|jjd|j�tSX|sc|jjd�tS|jjdt	|�|d �x'|j
j|�D]}|j|�q�WdS(Nsgot errno %d, done readingsgot no chunk, done readingsgot chunk size %d: %ri(
RPR�R�R�R�RmRvR�R�R+R�R�R�(R/R�te((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s N(
R5R6R7R)R�R.R�R`R�R�(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRxhs			R�cBs8eZdZedd�Zd�Zd�Zd�ZRS(s� this is used for feeding in chunks of stdout/stderr, and breaking it up
    into chunks that will actually be put into the internal buffers.  for
    example, if you have two processes, one being piped to the other, and you
    want that, first process to feed lines of data (instead of the chunks
    however they come in), OProc will use an instance of this class to chop up
    the data and feed it as lines to be sent down the pipe R�cCsX||_g|_d|_||_||_t|_tj�|_	t
d�|_dS(NiR�(ROR�tn_buffer_countR�R�R�t_use_up_buffer_firstRtRLockt_buffering_lockRgRm(R/tbuffer_typeR�R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.�s						cCsw|jjd�|jj�|jjd�z%|dkrHt|_n||_Wd|jj�|jjd�XdS(Ns/acquiring buffering lock for changing bufferings)got buffering lock for changing bufferingis.released buffering lock for changing buffering(RmRvR�R�R�R�ROR�(R/tnew_type((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s


cCs�|jjd|j�|jj�|jjd|j�z�|jdkr�y|j|j|j�Wq�|jjd�|jd�q�Xn|jdkr�|j	r�t
|_	|j}g|_|j|�|S|gS|jdkrg}|j|j|j�}x�t
r�|jd�}|dkr/Pn||d }|jr�d	j|j�j|j�|j|j�}|j|j�}g|_d|_n||d}|j|j|j��q
W|r|jj|j|j��|jt|�7_n|Sg}x�t
r�|jt|�|j}|dkr�d	j|j�j|j�|}||j }||j}|j|�g|_d|_q
|jj|�|jt|�7_Pq
W|SWd|jj�|jjd
|j�XdS(Ns9acquiring buffering lock to process chunk (buffering: %d)s3got buffering lock to process chunk (buffering: %d)is(detected binary data, changing bufferingiis
i����R�s<released buffering lock for processing chunk (buffering: %d)(RmRvROR�R�R,R�R�R�R�R�R�R�R�tfindR R]R�R+R�(R/R�tto_writettotal_to_writetnewlinetchunk_to_writetoveragetret((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��sl
				
				"


	
cCs�|jjd�|jj�|jjd�z/dj|j�j|j�}g|_|SWd|jj�|jjd�XdS(Ns,acquiring buffering lock for flushing buffers&got buffering lock for flushing bufferR�s+released buffering lock for flushing buffer(	RmRvR�R�R R�R]R�R�(R/R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�<s
	
(R5R6R7RR.R�R�R�(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s		Sccstd|��
dVWdQXdS(sd pushd is just a specialized form of args, where we're passing in the
    current working directory t_cwdN(Rn(RQ((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytpushdJscosatj}|j�}x3|j�D]%\}}|jd�}|||<q"WdV|j|�dS(s\ allows us to temporarily override all the special keyword parameters in
    a with context RbN(R�R�R�R�tlstripR
(RnR�R�told_argsR�R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyRnRs	tEnvironmentcBsqeZdZeddddddddd	d
ddd
g
�Zid�Zd�Zd�Zd�Zd�Z	RS(s� this allows lookups to names that aren't found in the global scope to be
    searched for as a program name.  for example, if "ls" isn't found in this
    module's scope, we consider it a system program and try to find it.

    we use a dict instead of just a regular object as the base class because the
    exec() statement used in this file requires the "globals" argument to be a
    dictionary R�R<RR�R$R�R8R9t__project_url__t__version__RnRR�cCs||_||_t|_dS(N(tglobsRR�tdisable_whitelist(R/R�R((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.�s		cCs||j|<dS(N(R�(R/RR((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__setitem__�scCs|dkrt|_dS||jks1|jrWy|j|SWqWtk
rSqWXn|dkrrtd��nt|�}|r�|S|jd�r�|j	d�r�t�nyt
j|SWntk
r�nXt|d|d�}|r�|St
j||j�S(Nt_disable_whitelistt__all__sJCannot import * from sh. Please import sh or import programs individually.t__tb_(R�R�R)t	whitelistR�R>R�RMR�R�RPR[RDR�R�R(R/RRHtbuiltin((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt__getitem__�s0	
	
cCstj|�dS(N(RPRS(R/RQ((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytb_cd�scCs
t|�S(N(Ra(R/R^((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytb_which�s(
R5R6R7R�R�R.R�R�R�R�(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�bs(		8	cBs�d}|jde�GHxuer�yed�}Wneefk
rJPnXye|dd�||UWqek
ryPqej	�GHqXqWdGHdS(Ns3
>> sh v{version}
>> https://github.com/amoffat/sh
tversionssh> s<dummy>tsingleR�(
tformatR�R�t	raw_inputRCtEOFErrortcompilet
SystemExitR�t
format_exc(R�tbannertline((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytrun_repl�s	
tSelfWrappercBs/eZid�Zd�Zd�Zd�ZRS(cCsdx6ddddgD]"}t||t||d��qWg|_||_tt�|�|_dS(Nt__builtins__R7R5t__package__(tsetattrRDR)t__path__t_SelfWrapper__self_moduleR�tglobalst_SelfWrapper__env(R/tself_moduleRR�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR.�s
 		cCs6t|d�r||j|<ntj|||�dS(Nt__env(RRRt__setattr__(R/RGR�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR�scCs |dkrt�n|j|S(NR(R�R(R/RG((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s	cKst|j|�S(N(R�R�(R/R�((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR	s(R5R6R.RR�R(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyR��s		t__main__ittestcCs�d|}t|�}|r�d|j�|fGHtjj�}||d<tj|tjjt	d�gt
jdd|�}|j�}|dkr�t
d�q�nd|j�GHdS(	Nspython%ssTesting %s, locale %rtLANGstest.pyiR�isCouldn't find %s, skipping(Rat
capitalizeRPR[R�t
subprocesstPopenRQR]tTHIS_DIRtsystargvR�texit(R�tlocalet
py_versiontpy_binR�R�treturn_code((s1/opt/imh-python/lib/python2.7/site-packages/sh.pytrun_test	s
	
s2.6s2.7s3.1s3.2s3.3s3.4sen_US.UTF-8tC(�R7R�R�tplatformtsystemtlowertImportErrorRtversion_infoRR�RPtreRReR[ttypesRt	functoolsRR4t
contextlibRRRRtioRRR�R�RR	RR�R
RRZRQtdirnameRVt__file__R
RlR�RRKR'RERTR�RR^R*R(RbtcollectionsRRjR8RtinputR�RRR�R�tdirR�R#R;R$R8R9tSIGABRTtSIGBUStSIGFPEtSIGILLtSIGINTRtSIGPIPEtSIGQUITtSIGSEGVR�tSIGSYSR�R�R<R�R?R=RMRFRaRdR�RgRzR{R�R�R$R0R?RER�R�R�R�R�R�R�R�R�R�RvR�R�R�R�R�RxR�R�RnRR�R�R�R5RR�RfR)RRtversionstlocalesR�R�R�tmodulesR/(((s1/opt/imh-python/lib/python2.7/site-packages/sh.pyt<module>s�	
		$3	 	 			0	�	�q				F	��	'				
			Y					S�g	"