wexpect | Windows variant of pexpect | Automation library
kandi X-RAY | wexpect Summary
kandi X-RAY | wexpect Summary
Wexpect is a Python module for spawning child applications and controlling them automatically. Wexpect 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. Wexpect is in the spirit of Don Libes' Expect, but Wexpect is pure Python. Other Expect-like modules for Python require TCL and Expect or require C extensions to be compiled. Wexpect does not use C, Expect, or TCL extensions. Original Pexpect should work on any platform that supports the standard Python pty module. While Wexpect works on Windows platforms. The Wexpect interface focuses on ease of use so that simple tasks are easy.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Spawn a child process
- Start a new child process
- Spawn a new child process
- Switch to the console
- Run the given command
- Spawn a new process
- Read loop
- Check if process is alive
- Start a child process
- Joins a list of arguments
- Implementation of write
- Searches for pattern matching patterns
- Read data from the cursor
- Terminate programmatically
- Send data to socket
- Send EOF
- Terminate the EOF
- Read lines from the file
- Terminate command
- Read data from the file
- Test the command to set echo echo
- Wait for the screen to finish
- Test the cmd executable
- Expect pattern_list
- Read data from the socket
- Read up to size bytes
wexpect Key Features
wexpect Examples and Code Snippets
import wexpect
prompt = '[A-Z]\:.+>'
child = wexpect.spawn('cmd.exe')
child.expect(prompt) # Wait for startup prompt
child.sendline('dir') # List the current directory
child.expect(prompt)
print(child.before) # Print the list
child.se
Community Discussions
Trending Discussions on wexpect
QUESTION
I have inherited a program made by someone else which makes considerable effort to be "interactive", using the following kind of syntax:
x = input("What is the value of x")
There are dozens of input
statements in nested if
blocks. To start refactoring this program I need to set up some benchmarks which can cover the whole code and automatically input all combinations of user input.
What is a quick way to get the program to accept user input via a python script?
EDIT
I have tried the windows alternative to pexpect
which seems to work OK.
ANSWER
Answered 2020-Aug-21 at 10:36You have few options:
- load a config file
- use cli arguments (sys.argv)
- use env variables (os.getenv(..))
I would go with getting 1 input from the caller. This input points to a config file (json,yaml,ini) that holds rest of the input you need. So you will change the logic of the code and ask fro the user input only when you can data in the config. Example:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install wexpect
You can use wexpect like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page