403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/lib/python3/dist-packages/IPython/core/magics/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3/dist-packages/IPython/core/magics/__pycache__/script.cpython-311.pyc
�

�@�c�/����dZddlZddlZddlZddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
mZmZmZddlmZddlmZddlmZmZmZmZdd	lmZd
�ZeGd�de����ZdS)
z5Magic functions for running cells in various scripts.�N)�CalledProcessError)�Thread)�Any�Dict�List�default)�magic_arguments)�
_AsyncIOProxy)�Magics�
cell_magic�
line_magic�magics_class)�	arg_splitc
�&�tjdtd���tjdtd���tjddd�	��tjd
td���tjdd
dd���g}|D]
}||��}�|S)z'single decorator for adding script argsz--outz�The variable in which to store stdout from the script.
            If the script is backgrounded, this will be the stdout *pipe*,
            instead of the stderr text itself and will not be auto closed.
            )�type�helpz--errz�The variable in which to store stderr from the script.
            If the script is backgrounded, this will be the stderr *pipe*,
            instead of the stderr text itself and will not be autoclosed.
            z--bg�
store_truez�Whether to run the script in the background.
            If given, the only way to see the output of the command is
            with --out/err.
            )�actionrz--procztThe variable in which to store Popen instance.
            This is used only when --bg option is given.
            z--no-raise-error�store_false�raise_errorz�Whether you should raise an error message in addition to
            a stream on stderr if you get a nonzero exit code.
            )r�destr)r	�argument�str)�f�args�args   �</usr/lib/python3/dist-packages/IPython/core/magics/script.py�script_argsrs���	� ��#��	
�	
�	
�	� ��#��	
�	
�	
�	� ��<��	
�	
�	
�	� ��3��	
�	
�	
�	� ��}�=��	
�	
�	
�9"�D�F�����C��F�F����H�c���eZdZdZed���Zed����d���Ze	d��d���Z
ed	����d���Zd�fd�	Z
d�Zd
�Zd�Zej��eed��d�������Zejdke_d�Zed��dd���Zd�Zd�Z�xZS)�ScriptMagicsz�Magics for talking to scripts
    
    This defines a base `%%script` cell magic for running a cell
    with a program in a subprocess, and registers a few top-level
    magics that call %%script with common interpreters.
    z�
        The event loop on which to run subprocesses

        Not the main event loop,
        because we want to be able to make blocking calls
        and have certain requirements we don't want to impose on the main loop.
        )rz�Extra script cell magics to define
        
        This generates simple wrappers of `%%script foo` as `%%foo`.
        
        If you want to add script magics that aren't on your path,
        specify them in script_paths
        T)�config�
script_magicsc�Z�gd�}tjdkr|�dg��|S)z$default to a common list of programs)�sh�bash�perl�ruby�python�python2�python3�pypy�nt�cmd)�os�name�extend)�self�defaultss  r�_script_magics_defaultz#ScriptMagics._script_magics_defaultasE��	
�	
�	
���7�d�?�?��O�O���
�
�
��rz�Dict mapping short 'ruby' names to full paths, such as '/opt/secret/bin/ruby'
        
        Only necessary for items in script_magics where the default path will not
        find the right interpreter.
        Nc����tt|���|���|���g|_tj|j��dS)N)�shell)�superr!�__init__�_generate_script_magics�bg_processes�atexit�register�kill_bg_processes)r2r6�	__class__s  �rr8zScriptMagics.__init__~sW���
�l�D�!�!�*�*��*�7�7�7��$�$�&�&�&�������.�/�/�/�/�/rc�.�|���dS�N)r=�r2s r�__del__zScriptMagics.__del__�s����� � � � � rc�d�|jd}|jD]}|�|��||<�dS)N�cell)�magicsr#�_make_script_magic)r2�cell_magicsr0s   rr9z$ScriptMagics._generate_script_magics�sE���k�&�)���&�	>�	>�D� $� 7� 7�� =� =�K����	>�	>rc������j�||���tj��t��fd�����}djdit����|_|S)zAmake a named magic, that calls %%script with a particular programc�H��|r��d|��}n�}��||��S)N� )�shebang)�linerD�scriptr2s  ��r�named_script_magicz;ScriptMagics._make_script_magic.<locals>.named_script_magic�s8����
�"(�&�&�$�$�/������<�<��d�+�+�+rz�%%{name} script magic
        
        Run cells with {script} in a subprocess.
        
        This is a shortcut for `%%script {script}`
        �)�script_paths�getr	r�format�locals�__doc__)r2r0rNrMs`  @rrFzScriptMagics._make_script_magic�s������"�&�&�t�T�2�2��	�	(�	*�	*�	�	,�	,�	,�	,�	,�
��
+�	*�	,�	�	�

�	�	�
�X�X�	�	�	�"�"�!rrMc	�������
����j�{tjdkr&tj������
ntj���
�
�_t
�
jd���}|���n�j�
�
fd�}�fd����fd�}t|tj�
d���	��}�jj�
|��\�}	|tj|tjjtjjtjjd
�����nF#t"$r9}|jt$jkrt)d|dz��Yd}~dS�d}~wwxYw��d
��s�d
z
���dd����j�r>�j��������g��jr(t9�j�
���jj�j<n���j���j r(t9�j!�
���jj�j <n���j!���
�"����fd����j#rXt9��
��}	t9�j�
��|	_t9�j!�
��|	_!|	�jj�j#<dS	||�������n9#tH$�r+	��%tLj'��|tj(��)��d������j*�t)d��YdS��+��|tj(��)��d������j*�t)d��YdS��,��t)d��n;#t"$rYn/tZ$r#}t)d�j.|fz��Yd}~nd}~wwxYwYdSwxYw�j/r$�j*dkr�j*pd}
ta|
����dSdS)a�Run a cell via a shell command

        The `%%script` line is like the #! line of script,
        specifying a program (bash, perl, ruby, etc.) with which to run.

        The rest of the cell is run by that program.

        Examples
        --------
        ::

            In [1]: %%script bash
               ...: for i in 1 2 3; do
               ...:   echo $i
               ...: done
            1
            2
            3
        N�win32T)�target�daemonc�R��tj|������S)z&Call a coroutine on the asyncio thread)�asyncio�run_coroutine_threadsafe�result)�coro�
event_loops �r�	in_threadz'ScriptMagics.shebang.<locals>.in_thread�s"����3�D�*�E�E�L�L�N�N�Nrc����K�	|����d{V���d��}|sdS|r|�jj|<n)|�|��|����m)NT�utf8)�readline�decoder6�user_ns�write�flush)�stream�
stream_arg�file_objectrLr2s    �r�_handle_streamz,ScriptMagics.shebang.<locals>._handle_stream�s������
(�$�o�o�/�/�/�/�/�/�/�/�7�7��?�?�����E��(�59�D�J�&�z�2�2��%�%�d�+�+�+��%�%�'�'�'�
(rc���K�|j�|��|j���tj�|j�jtj����}tj�|j�j	tj����}tj
||g���d{V��|�
���d{V��dSr@)�stdinre�closerZ�create_task�stdout�out�sys�stderr�err�wait)�processrD�stdout_task�stderr_taskrjrs    ��r�_stream_communicatez1ScriptMagics.shebang.<locals>._stream_communicate�s�������M����%�%�%��M���!�!�!�!�-���w�~�t�x���D�D���K�"�-���w�~�t�x���D�D���K��,��[�9�:�:�:�:�:�:�:�:�:��,�,�.�.� � � � � � � � � r�win)�posix)rorrrlzCouldn't find program: %rr�
ra�replacec�V��tj���������Sr@)rZ�Task�_run_script)rD�pr2�to_closes����r�<lambda>z&ScriptMagics.shebang.<locals>.<lambda>
s#�����T�%5�%5�a��x�%H�%H�I�I�r皙�����?)�timeoutzProcess is interrupted.zProcess is terminated.zProcess is killed.z/Error while terminating subprocess (pid=%i): %si����)1r^rq�platformrZ�WindowsProactorEventLoopPolicy�new_event_loopr�run_forever�startr�
startswithrK�parser�parse_known_args�create_subprocess_exec�
subprocess�PIPE�OSError�errno�ENOENT�print�endswith�encode�bgr:�append�_gc_bg_processesrpr
ror6rdrsrr�call_soon_threadsafe�proc�KeyboardInterrupt�send_signal�signal�SIGINT�wait_forrt�
returncode�	terminate�kill�	Exception�pidrr)r2rLrD�asyncio_threadr_rx�argvr.�e�
proc_proxy�rcrjrr^r�r�s` `        @@@@@rrKzScriptMagics.shebang�s����������4�?�"��|�w�&�&�%�C�E�E�T�T�V�V�
�
�$�3�5�5�
�(�D�O�$�:�+A�$�O�O�O�N�� � �"�"�"�"���J�	O�	O�	O�	O�	O�		(�		(�		(�		(�		(�
	!�
	!�
	!�
	!�
	!�
	!�����)@�)@��)G�)G�%G�H�H�H���L�'�8�8��>�>�	��c�	��	��.��"�-�2�"�-�2�!�,�1�	�����A�A���	�	�	��w�%�,�&�&��1�C��F�:�;�;�;������������	�����}�}�T�"�"�	��D�L�D��{�{�6�9�-�-���7�	���$�$�Q�'�'�'��!�!�#�#�#��H��x�
*�/<�Q�X�z�/R�/R��
�"�4�8�,�,������)�)�)��x�
*�/<�Q�X�z�/R�/R��
�"�4�8�,�,������)�)�)��+�+�I�I�I�I�I�I�I�
�
�
��y�
;�*�1�j�9�9�
�$1�!�(�J�$G�$G�
�!�$1�!�(�J�$G�$G�
�!�0:��
�"�4�9�-��F�	��I�)�)�!�T�2�2�3�3�3�3�� �	�	�	�
V��
�
�f�m�,�,�,��	�'�*�1�6�6�8�8�S�A�A�A�B�B�B��<�+��3�4�4�4��F�F����
�
�
��	�'�*�1�6�6�8�8�S�A�A�A�B�B�B��<�+��2�3�3�3��F�F��������*�+�+�+�+���
�
�
����
V�
V�
V��G�1�5�RS�*�T�U�U�U�U�U�U�U�U�����
V�����F�F�%	����(��	/���� 1� 1���#��B�$�R��.�.�.�	/�	/� 1� 1su�3A	D=�=
F�-E;�:E;�;F�:L�Q�A&P�AP�$#P�Q�
Q�Q�	Q�P;�6Q�;Q�Q�Qrzc��K�|j�|��|j����d{V��|j���|j����d{V��|����d{V��|D]}|����d{V���|���dS)z1callback for running the script in the backgroundN)rlre�drainrm�wait_closedrt�readr�)r2r�rDr��ss     rrzScriptMagics._run_script5s�����	
��
�
�d�����g�m�m�o�o��������	��
�
�����g�!�!�#�#�#�#�#�#�#�#�#��f�f�h�h���������	�	�A��&�&�(�(�N�N�N�N�N�N�N�N��������r�
killbgscripts�c�L�|���td��dS)z9Kill all BG processes started by %%script and its family.z%All background processes were killed.N)r=r�)r2�_nouse_s  rr�zScriptMagics.killbgscriptsCs+��	
��� � � �
�5�6�6�6�6�6rc�.�|jsdS|jD]1}|j�(	|�tj���*#Y�.xYw�2tjd��|���|jsdS|jD]&}|j�	|����#Y�#xYw�'tjd��|���|jsdS|jD]&}|j�	|�	���#Y�#xYw�'|���dS)z.Kill all BG processes which are still running.Nr�)
r:r�r�r�r��time�sleepr�r�r�)r2r�s  rr=zScriptMagics.kill_bg_processesIsY��� �	��F��"�	�	�A��|�#���M�M�&�-�0�0�0�0����D����	$�
	
�
�3����������� �	��F��"�	�	�A��|�#���K�K�M�M�M�M����D����	$�
	
�
�3����������� �	��F��"�	�	�A��|�#���F�F�H�H�H�H����D����	$�
	
�������s �;�?�B�B�$C9�9C=c�2�d�|jD��|_dS)Nc� �g|]}|j�	|��Sr@)r�)�.0r�s  r�
<listcomp>z1ScriptMagics._gc_bg_processes.<locals>.<listcomp>js��R�R�R�1�Q�\�=Q�Q�=Q�=Q�=Qr)r:rAs rr�zScriptMagics._gc_bg_processesis!��R�R��(9�R�R�R����rr@)r�)�__name__�
__module__�__qualname__rTrr^r�tagr#rr4rrPr8rBr9rFr	rrrKr/r0�__skip_doctest__rr
r�r=r��
__classcell__)r>s@rr!r!Es����������������J��D�����
�c��c����
�W�_��������(�4�����
�c��c���
�0�0�0�0�0�0�!�!�!�>�>�>�
"�"�"�4%�_�$�&�&���Z����H/�H/����[�'�&�H/�T "�w�'�1�G�� � � ��Z�� � �7�7�7�!� �7�
 � � �@S�S�S�S�S�S�Srr!)rTrZr;r�r/r�rqr�r�r�	threadingr�	traitletsrrrr�IPython.corer	�IPython.core.async_helpersr
�IPython.core.magicrrr
r�IPython.utils.processrrr!rOrr�<module>r�sR��;�;�
����
�
�
�
�����	�	�	�	�
�
�
�
�
�
�
�
�����)�)�)�)�)�)�������.�.�.�.�.�.�.�.�.�.�.�.�(�(�(�(�(�(�4�4�4�4�4�4�K�K�K�K�K�K�K�K�K�K�K�K�+�+�+�+�+�+�'
�'
�'
�T�dS�dS�dS�dS�dS�6�dS�dS���dS�dS�dSr

Youez - 2016 - github.com/yon3zu
LinuXploit