Skip to main content

Asyncio-based Telnet library

Project description

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.

Documentation License: Apache License 2.0 PyPi Version PyPi downloads

  • 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

Here is a simple example of using in an asynchronous context.

import asyncio
from asyncio_telnet import Telnet


async def main():
    tn = Telnet()
    await tn.open('example.com')
    response = await tn.read_until_eof()
    return response

if __name__ == '__main__':
    result = asyncio.run(main())
    print(result)


# example of successful execution
b'\n***************** User Access Login ********************\r\n\r\nUser:'

For synchronous usage, you can use the library in a similar way by simply specifying sync_mode=True.

from asyncio_telnet import Telnet


def main():
    # by specifying sync_mode=True, a wrapper for calling
    # asynchronous methodssynchronously is activated internally.
    tn = Telnet(sync_mode=True)
    # now it is possible to directly invoke asynchronous methods through the wrapper
    tn.open('example.com')
    response = tn.read_until_eof()
    return response

if __name__ == '__main__':
    result = main()
    print(result)


# example of successful execution
b'\n***************** User Access Login ********************\r\n\r\nUser:'

Here is a simple example of using in an asynchronous context with a timeout of 5 seconds. By default, the timeout is set to 30 seconds.

async def main():
    tn = Telnet(timeout=5)
    await tn.open('example.com')
    response = await tn.read_until_eof()
    return response

if __name__ == '__main__':
    result = asyncio.run(main())
    print(result)


# example of a timeout occurrence
ValueError: Timeout connecting to example.com:23

Feel free to check the documentation for more detailed information and examples.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

asyncio-telnet-0.1.17.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

asyncio_telnet-0.1.17-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file asyncio-telnet-0.1.17.tar.gz.

File metadata

  • Download URL: asyncio-telnet-0.1.17.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for asyncio-telnet-0.1.17.tar.gz
Algorithm Hash digest
SHA256 035c990ced55a29534dcb8aac63fd4943227ee207e2de49682ea4cf265094104
MD5 1b6152db3a6f1d08645df17ff50d3963
BLAKE2b-256 4c62994a3f12c34b355f5b315edbf3f8852e09802ac605c161d5ab43671da3b0

See more details on using hashes here.

File details

Details for the file asyncio_telnet-0.1.17-py3-none-any.whl.

File metadata

File hashes

Hashes for asyncio_telnet-0.1.17-py3-none-any.whl
Algorithm Hash digest
SHA256 a7c088441ff0b8e096f68c999e4d9d4531cc325237bf2000931dfd78435124a6
MD5 5d3731761cd35bbf12ea846a5b17e202
BLAKE2b-256 2c1a90406724d53c9cbd56e2755f14a962a16cf882497df02f627f8824279ad3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page