Python Telnet Utility: asyncio-powered
The asyncio-telnet library designed for convenient interaction with Telnet devices in both synchronous and asynchronous modes, making the process straightforward and flexible in various usage scenarios.
- Support for Asynchrony and Synchrony: Harness the power of asyncio for efficient and non-blocking communication with Telnet servers. With this library, you have the option to choose between asynchronous and synchronous modes, depending on the requirements of your project.
- Ease of Use: The library provides a user-friendly interface for both synchronous and asynchronous cases, making it adaptable to different project needs.
- Telnet Protocol Handling: Transparently handles the intricacies of the Telnet protocol, allowing you to focus on the logic of your application.
- Flexible Integration: Easily integrate Telnet functionality into your Python applications with a simple API.
Installation
You can install the library using pip. Make sure you have Python 3.6 or later installed.
pip install asyncio-telnet
Usage
Example: Asynchronous Telnet Connection with Default Timeout
import asyncio
from asyncio_telnet import Telnet
async def main():
tn = Telnet()
await tn.open('example.com')
await tn.write(b'Vladimir\r\n')
response = await tn.read_until_eof()
await tn.close()
return response
if __name__ == '__main__':
result = asyncio.run(main())
print(result)
# Example of successful execution:
# b'\n***************** User Access Login ********************\r\n\r\nUser:'
Example: Synchronous Telnet Connection
from asyncio_telnet import Telnet
def main():
tn = Telnet(sync_mode=True)
tn.open('example.com')
response = tn.read_until_eof()
tn.close()
return response
if __name__ == '__main__':
result = main()
print(result)
# Example of successful execution:
# b'\n***************** User Access Login ********************\r\n\r\nUser:'
Example: Asynchronous Telnet Connection with Custom Timeout.
By default, the timeout is set to 30 seconds.
import asyncio
from asyncio_telnet import Telnet
async def main():
tn = Telnet(timeout=5)
try:
await tn.open('example.com')
response = await tn.read_until_eof()
await tn.close()
return response
except ValueError as e:
print(f"Example of a timeout occurrence: {e}")
if __name__ == '__main__':
asyncio.run(main())
# Example response:
# Example of a timeout occurrence: Timeout connecting to example.com:23
Example: Asynchronous Telnet Connection with Write Operation
import asyncio
from asyncio_telnet import Telnet
async def main():
tn = Telnet()
await tn.open('example.com')
await tn.write(b'Vladimir\r\n')
response = await tn.read_until_eof()
await tn.close()
return response
if __name__ == '__main__':
result = asyncio.run(main())
print(result)
# Example of successful execution:
# b'\n***************** User Access Login ********************\r\n\r\nUser:Vladimir\r\nPassword:'
Feel free to check the documentation and examples for more detailed information.
Metadata
Release files for asyncio-telnet 0.1.21
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| asyncio-telnet-0.1.21.tar.gz | 9.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| asyncio_telnet-0.1.21-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.3 kB
Release files / asyncio-telnet-0.1.21.tar.gz
| Download URL | asyncio-telnet-0.1.21.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d61ba2470111c144690275ba492539ccc63be8e4a0dd34f4327dd4dea188d0bd
|
|
BLAKE2b-256 checksum How to use checksums |
620078cfda408e71dcab9038f9926411b80538bc0b366d6eb1c19f377c98eeba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|
Release files / asyncio_telnet-0.1.21-py3-none-any.whl
| Download URL | asyncio_telnet-0.1.21-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ff96907f4f718f58fc99c7ff30ab05efb735061d9dc782877ec51ca358772b73
|
|
BLAKE2b-256 checksum How to use checksums |
7e658175a6dd07f7e45df26f931338a2994a90516889aa618b90fb61b1909318
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.0
|