Linux ns1.utparral.edu.mx 6.8.0-79-generic #79~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug 15 16:54:53 UTC 2 x86_64
Apache/2.4.58 (Unix) OpenSSL/1.1.1w PHP/8.2.12 mod_perl/2.0.12 Perl/v5.34.1
: 10.10.1.9 | : 10.10.1.254
Cant Read [ /etc/named.conf ]
daemon
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
README
+ Create Folder
+ Create File
/
usr /
share /
hplip /
base /
pexpect /
__pycache__ /
[ HOME SHELL ]
Name
Size
Permission
Action
__init__.cpython-310.pyc
61.37
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : __init__.cpython-310.pyc
o �/�akD � @ s� d Z zEddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZde_W n ey\ e�� d Zeee�d ��w dZdZg d�Zejd d kZG d d� de�ZG dd � d e�ZG dd� de�Z d$dd�Z d$dd�Z dd� Z!G dd� de"�Z#G dd� de#�Z$G dd� de"�Z%G dd� de"�Z&d d!� Z'd"d#� Z(dS )%a� Pexpect is a Python module for spawning child applications and controlling them automatically. Pexpect can be used for automating interactive applications such as ssh, ftp, passwd, telnet, etc. It can be used to a automate setup scripts for duplicating software package installations on different servers. It can be used for automated software testing. Pexpect is in the spirit of Don Libes' Expect, but Pexpect is pure Python. Other Expect-like modules for Python require TCL and Expect or require C extensions to be compiled. Pexpect does not use C, Expect, or TCL extensions. It should work on any platform that supports the standard Python pty module. The Pexpect interface focuses on ease of use so that simple tasks are easy. There are two main interfaces to the Pexpect system; these are the function, run() and the class, spawn. The spawn class is more powerful. The run() function is simpler than spawn, and is good for quickly calling program. When you call the run() function it executes a given program and then returns the output. This is a handy replacement for os.system(). For example:: pexpect.run('ls -la') The spawn class is the more powerful interface to the Pexpect system. You can use this to spawn a child program then interact with it by sending input and expecting responses (waiting for patterns in the child's output). For example:: child = pexpect.spawn('scp foo user@example.com:.') child.expect('Password:') child.sendline(mypassword) This works even for commands that ask for passwords or other input outside of the normal stdio streams. For example, ssh reads input directly from the TTY device which bypasses stdin. Credits: Noah Spurrier, Richard Holden, Marco Molteni, Kimberley Burchett, Robert Stone, Hartmut Goebel, Chad Schroeder, Erick Tryzelaar, Dave Kirby, Ids vander Molen, George Todd, Noel Taylor, Nicolas D. Cesar, Alexander Gattin, Jacques-Etienne Baudoux, Geoffrey Marshall, Francisco Lourenco, Glen Mabey, Karthik Gurusamy, Fernando Perez, Corey Minyard, Jon Cohen, Guillaume Chazarain, Andrew Ryan, Nick Craig-Wood, Andrew Stone, Jorgen Grahn, John Spiegel, Jan Grant, and Shane Kerr. Let me know if I forgot anyone. Pexpect is free, open source, and all that good stuff. http://pexpect.sourceforge.net/ PEXPECT LICENSE This license is approved by the OSI and FSF as GPL-compatible. http://opensource.org/licenses/isc-license.txt Copyright (c) 2012, Noah Spurrier <noah@noah.org> PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. � NT� z� A critical module was not found. Probably this operating system does not support it. Pexpect is intended for UNIX-like operating systems.z3.1� )�ExceptionPexpect�EOF�TIMEOUT�spawn�spawnu�run�runu�which�split_command_line�__version__�__revision__� c s0 e Zd ZdZ� fdd�Zdd� Zdd� Z� ZS )r z9Base class for all exceptions raised by this module. c s t t| ��|� || _d S �N)�superr �__init__�value)�selfr �� __class__� �)/usr/share/hplip/base/pexpect/__init__.pyr g s zExceptionPexpect.__init__c C s t | j�S r )�strr �r r r r �__str__k s zExceptionPexpect.__str__c C s4 t �t�� d �}dd� |D �}t �|�}d�|�S )z�This returns an abbreviated stack trace with lines that only concern the caller. In other words, the stack trace inside the Pexpect module is not included. � c S s g | ] }d |d vr|�qS )zpexpect/__init__r r )�.0�itemr r r � <listcomp>t � z.ExceptionPexpect.get_trace.<locals>.<listcomp>r )� traceback� extract_tb�sys�exc_info�format_list�join)r �tblistr r r � get_tracen s zExceptionPexpect.get_trace)�__name__� __module__�__qualname__�__doc__r r r( � __classcell__r r r r r c s r c @ � e Zd ZdZdS )r zRRaised when EOF is read from a child. This usually means the child has exited.N�r) r* r+ r, r r r r r y � r c @ r. )r z-Raised when a read time exceeds the timeout. Nr/ r r r r r ~ r0 r ���Fc C s t | |||||||td� S )a� This function runs the given command; waits for it to finish; then returns all output as a string. STDERR is included in output. If the full path to the command is not given then the path is searched. Note that lines are terminated by CR/LF (\r\n) combination even on UNIX-like systems because this is the standard for pseudottys. If you set 'withexitstatus' to true, then run will return a tuple of (command_output, exitstatus). If 'withexitstatus' is false then this returns just command_output. The run() function can often be used instead of creating a spawn instance. For example, the following code uses spawn:: from pexpect import * child = spawn('scp foo user@example.com:.') child.expect('(?i)password') child.sendline(mypassword) The previous code can be replace with the following:: from pexpect import * run('scp foo user@example.com:.', events={'(?i)password': mypassword}) **Examples** Start the apache daemon on the local machine:: from pexpect import * run("/usr/local/apache/bin/apachectl start") Check in a file using SVN:: from pexpect import * run("svn ci -m 'automatic commit' my_file.py") Run a command and capture exit status:: from pexpect import * (command_output, exitstatus) = run('ls -l /bin', withexitstatus=1) The following will run SSH and execute 'ls -l' on the remote machine. The password 'secret' will be sent if the '(?i)password' pattern is ever seen:: run("ssh username@machine.example.com 'ls -l'", events={'(?i)password':'secret\n'}) This will start mencoder to rip a video from DVD. This will also display progress ticks every 5 seconds as it runs. For example:: from pexpect import * def print_ticks(d): print d['event_count'], run("mencoder dvd://1 -o video.avi -oac copy -ovc copy", events={TIMEOUT:print_ticks}, timeout=5) The 'events' argument should be a dictionary of patterns and responses. Whenever one of the patterns is seen in the command out run() will send the associated response string. Note that you should put newlines in your string if Enter is necessary. The responses may also contain callback functions. Any callback is function that takes a dictionary as an argument. The dictionary contains all the locals from the run() function, so you can access the child spawn object or any other variable defined in run() (event_count, child, and extra_args are the most useful). A callback may return True to stop the current run process otherwise run() continues until the next event. A callback may also return a string which will be sent to the child. 'extra_args' is not used by directly run(). It provides a way to pass data to a callback function through run() through the locals dictionary passed to a callback. ��timeout�withexitstatus�events� extra_args�logfile�cwd�env�_spawn)�_runr )�commandr3 r4 r5 r6 r7 r8 r9 r r r r � s I�r c K s"