Get an available port. Checks first for prefered port in case its available, if not returns random.
Project description
get-port
Get an available port. Checks first for prefered port in case its available, if not returns random. Python implementation of the get-port idea by @sindresorhus.
Installation.
Available via PyPy.
pip install get-port
Usage.
Available in terminal:
get-port [prefered-port-optional]
Usage in code:
# Gets the actual port. Send prefered_port to pick if available.
from get_port import get_port
port = get_port(prefered_port)
# Check if port is available. Returns tuple: (Boolean, Dict)
from get_port import port_available
is_available = port_available(your_port)
# Find random free port. Returns tuple: (Port, Dict)
from get_port import find_free_port
port = find_free_port()
License
MIT.
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
get-port-0.0.1.tar.gz
(3.5 kB
view hashes)