Skip to main content

Python client for Gnetcli GRPC server

Gnetcli provides a universal way to execute arbitrary commands using a CLI, eliminating the need for screen scraping with expect.

See documentation on gnetcli server.

Example:

from gnetclisdk.client import Credentials, Gnetcli, HostParams
import os, asyncio

async def example():
    api = Gnetcli(insecure_grpc=True)
    # api = Gnetcli(insecure_grpc=True, auth_token="Basic " + base64.b64encode(f"{username}:{password}".encode('utf-8')).decode("ascii")
    dev_creds = Credentials(os.environ.get("LOGIN"), os.environ.get("PASSWORD"))
    res = await api.cmd(hostname="myhost", cmd="dis clock", host_params=HostParams(device="huawei", credentials=dev_creds))
    print("err=%s status=%s out=%s" % (res.error, res.status, res.out))

asyncio.run(example())

Output:

err=b'' status=0 out=b'2023-11-10 09:31:58\nFriday\nTime Zone(UTC) : UTC'

Tests

From this directory, with Go on PATH (to build gnetcli_server and gswitch):

python3 -m venv .venv && . .venv/bin/activate
pip install -r requirements.txt -r requirements-test.txt -e .
pytest tests/

Optional: GNETCLI_TEST_PREBUILT_DIR — directory that already contains gnetcli_server and gswitch binaries (skip go build in tests).

Download files

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

Source Distribution

gnetclisdk-1.3.5.tar.gz (18.6 kB view details)

Uploaded Source

Built Distribution

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

gnetclisdk-1.3.5-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

Details for the file gnetclisdk-1.3.5.tar.gz.

File metadata

  • Download URL: gnetclisdk-1.3.5.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gnetclisdk-1.3.5.tar.gz
Algorithm Hash digest
SHA256 97b6f28b982162cc117b07e6b0eaa496a79b71f48a3021c0ebf29e2f2e79772f
MD5 cdb0536f6610104b86e0306f25128791
BLAKE2b-256 c782da7fcb311d34bd9b1cb2eac72588d23349faeaa7280c878714d19995050e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gnetclisdk-1.3.5.tar.gz:

Publisher: publish-to-pypi.yml on annetutil/gnetcli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gnetclisdk-1.3.5-py3-none-any.whl.

File metadata

  • Download URL: gnetclisdk-1.3.5-py3-none-any.whl
  • Upload date:
  • Size: 17.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for gnetclisdk-1.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 940b2416076c6d6855ce76487f57e1d25b9a509dcbcb83f3552abb9bcb1a7c5d
MD5 57eb5ea2f5546ec77084a0f6cc62126d
BLAKE2b-256 b27bf1e2e23bd77e8fdbaa55d5835fb6e75f6f9a1a176f8b59ca1dd48b19a5a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for gnetclisdk-1.3.5-py3-none-any.whl:

Publisher: publish-to-pypi.yml on annetutil/gnetcli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.3.5

Supported by

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