Skip to main content

python-nabto-client

Python Wrapper for the Linux and macOS native Nabto Client SDKs.

Requirements

  • Python 3.6+
  • python3-dev package for Debian distributions
  • Linux or macOS (Windows is not supported - let us know if you need this!)

Installation

Install using pip...

pip install -i https://test.pypi.org/simple/ nabto-client

Example

Let's take a look at a quick example of using nabto_client to open a session and a tunnel.

import nabto_client

NABTO_HOME_DIRECTORY = "/home/nabto/example"

USER = "user"
PASSWORD = "password"

LOCAL_PORT = 7000
NABTO_HOST = "example.appmyproduct.com"
REMOTE_HOST = "localhost"
REMOTE_PORT = 8000

# Initializes the Nabto client API
nabto_client.startup(NABTO_HOME_DIRECTORY)

# Creates a Nabto self signed profile
nabto_client.createSelfSignedProfile(USER, PASSWORD)

with nabto_client.NabtoSession(USER, PASSWORD) as session:
    with nabto_client.NabtoTunnel(session, LOCAL_PORT, NABTO_HOST, REMOTE_HOST, REMOTE_PORT) as port:
        print(f'Opened tunnel on port {port}')
        ...

# Releases any resources held by the Nabto client API
nabto_client.shutdown()

Tunnel status

The example above doesn't allow to query the current status of the tunnel because the context manager returns the port not the tunnel object.

If you want to query the tunnel status, don't use the context manager, instead create and open a tunnel like this:

tunnel = nabto_client.NabtoTunnel(session, LOCAL_PORT, NABTO_HOST, REMOTE_HOST, REMOTE_PORT)
print(f'Tunnel status is {tunnel.status()}') # -1 or TunnelStatus.CLOSED
port = tunnel.openTcp()
print(f'Opened tunnel on port {port}')
print(f'Tunnel status is {tunnel.status()}') # 3 or TunnelStatus.LOCAL
# ... do something with the tunnel
tunnel.close()
if nabto_client.TunnelStatus.CLOSED == tunnel.status():
    print(f'Tunnel is closed')

You can also run example/cli.py for an interactive example.

python example/cli.py --device example.appmyproduct.com

Metadata

Release files for nabto-client 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nabto-client 1.0.0
File Size Uploaded
nabto_client-1.0.0.tar.gz 23.5 MB Details

Release files / nabto_client-1.0.0.tar.gz

Download URL nabto_client-1.0.0.tar.gz
Size 23.5 MB
Tags Source
SHA-256 checksum
How to use checksums
f47159ee3f5f48ca0f37ea59c3032b66faaab83fd1e3ad4a274d2346e3de4ec0
BLAKE2b-256 checksum
How to use checksums
e1aabd5bb7f87c2f54f1449fbf29e874962fe1127c95d5740d4b170cd61e1deb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

Release history Release notifications | RSS feed

1.0.1

1 release file

This release

1.0.0 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page