B
    è?F[ß
  ã               @   sj   d dl mZ d dlZd dlZyd dlZd dlZdZW n ek
rL   dZY nX dd„ Zdd„ Z	d	d
„ Z
dS )é    )Úprint_functionNTFc             C   s   t rt| ƒ nt| ƒ d S )N)Úhas_termiosÚposix_shellÚwindows_shell)Úchan© r   ú7lib/python3.7/site-packages/boto/mashups/interactive.pyÚinteractive_shell    s    
r	   c             C   s  dd l }t tj¡}zÚt tj ¡ ¡ t tj ¡ ¡ |  	d¡ xª|  | tjgg g ¡\}}}| |krºy>|  
d¡}t|ƒdkrŠtddd P tj |¡ tj ¡  W n tjk
r¸   Y nX tj|krBtj d¡}t|ƒdkrÞP |  |¡ qBW W d t tjtj|¡ X d S )Nr   g        i   z
*** EOF
ú )Úendé   )ÚselectÚtermiosZ	tcgetattrÚsysÚstdinÚttyZsetrawÚfilenoZ	setcbreakZ
settimeoutÚrecvÚlenÚprintÚstdoutÚwriteÚflushÚsocketZtimeoutÚreadÚsendZ	tcsetattrZ	TCSADRAIN)r   r   ZoldttyÚrÚwÚeÚxr   r   r   r   '   s0    


r   c             C   st   dd l }tj d¡ dd„ }|j|| fd}| ¡  y&x tj d¡}|sJP |  |¡ q8W W n t	k
rn   Y nX d S )Nr   zALine-buffered terminal emulation. Press F6 or ^Z to send EOF.

c             S   sF   x@|   d¡}|s(tj d¡ tj ¡  P tj |¡ tj ¡  qW d S )Né   z
*** EOF ***

)r   r   r   r   r   )ZsockÚdatar   r   r   ÚwriteallL   s    

zwindows_shell.<locals>.writeall)ÚtargetÚargsr   )
Ú	threadingr   r   r   ZThreadÚstartr   r   r   ÚEOFError)r   r%   r"   ÚwriterÚdr   r   r   r   G   s    
r   )Z
__future__r   r   r   r   r   r   ÚImportErrorr	   r   r   r   r   r   r   Ú<module>   s   
 