Skip to main content

TCP port monitoring utilities

Project description

https://img.shields.io/pypi/v/portend.svg https://img.shields.io/pypi/pyversions/portend.svg https://img.shields.io/travis/jaraco/portend/master.svg https://img.shields.io/appveyor/ci/jaraco/portend/master.svg https://readthedocs.org/projects/portend/badge/?version=latest

por·tend pôrˈtend/ verb

be a sign or warning that (something, especially something momentous or calamitous) is likely to happen.

Usage

Use portend to monitor TCP ports for bound or unbound states.

For example, to wait for a port to be occupied, timing out after 3 seconds:

portend.occupied('www.google.com', 80, timeout=3)

Or to wait for a port to be free, timing out after 5 seconds:

portend.free('::1', 80, timeout=5)

The portend may also be executed directly. If the function succeeds, it returns nothing and exits with a status of 0. If it fails, it prints a message and exits with a status of 1. For example:

python -m portend localhost:31923 free
(exits immediately)

python -m portend -t 1 localhost:31923 occupied
(one second passes)
Port 31923 not bound on localhost.

Portend also exposes a find_available_local_port for identifying a suitable port for binding locally:

port = portend.find_available_local_port()
print(port, "is available for binding")

Portend additionally exposes the lower-level port checking functionality in the Checker class, which currently exposes only one public method, assert_free.

portend.Checker().assert_free(‘localhost’, 31923)

If assert_free is passed a host/port combination that is occupied by a bound listener (i.e. a TCP connection is established to that host/port), assert_free will raise a PortNotFree exception.

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

portend-2.3.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

portend-2.3-py2.py3-none-any.whl (5.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file portend-2.3.tar.gz.

File metadata

  • Download URL: portend-2.3.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for portend-2.3.tar.gz
Algorithm Hash digest
SHA256 b7ce7d35ea262415297cbfea86226513e77b9ee5f631d3baa11992d663963719
MD5 c1f36f2126da940ca5192dd1488b4f28
BLAKE2b-256 ab8f70f5babd4a6a7c6a471e834c53be3ee3c89a6b3b16d6a85b2d25f2dc2671

See more details on using hashes here.

File details

Details for the file portend-2.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for portend-2.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f5c99a1aa1655733736bb0283fee6a1e115e18db500332bec8e24c43f320d8e8
MD5 21f9c233d3aa6f2e9d9017e447c18e66
BLAKE2b-256 814321afd5914b74d4271184ee76f4093b45aa6a580dc6627d72dfc33664c6ac

See more details on using hashes here.

Supported by

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