Skip to main content

xpipe_client

GitHub license PyPI version

Python client for the XPipe API

Installation

python3 -m pip install xpipe_client

Usage

from xpipe_client import Client

# By default, Client() will read the API key from xpipe_auth on the local filesystem
# and talk to the XPipe API on localhost.  To connect to a remote instance with an API
# key, use Client(token="foo", base_url = "http://servername:21723")
client = Client()

# connection_query accepts glob-based filters on the category, connection name, and connection type
all_connections = client.connection_query()

# Each connection includes uuid, category, connection, and type information
first_connection_uuid = all_connections[0]["uuid"]

# Before any shell commands can be run, a shell session must be started on a connection
client.shell_start(first_connection_uuid)

# Prints {'exitCode': 0, 'stdout': 'hello world', 'stderr': ''}
print(client.shell_exec(first_connection_uuid, "echo hello world"))

# Clean up after ourselves
client.shell_stop(first_connection_uuid)

There's also an async version of the client that can be accessed as AsyncClient:

import asyncio
from xpipe_client import AsyncClient


async def main():
    # By default, AsyncClient() will read the API key from xpipe_auth on the local filesystem
    # and talk to the XPipe API on localhost.  To connect to a remote instance with an API
    # key, use Client(token="foo", base_url = "http://servername:21723")
    client = AsyncClient()

    # connection_query accepts glob-based filters on the category, connection name, and connection type
    all_connections = await client.connection_query()
    
    # Each connection includes uuid, category, connection, and type information
    first_connection_uuid = all_connections[0]["uuid"]
    
    # Before any shell commands can be run, a shell session must be started on a connection
    await client.shell_start(first_connection_uuid)
    
    # Prints {'exitCode': 0, 'stdout': 'hello world', 'stderr': ''}
    print(await client.shell_exec(first_connection_uuid, "echo hello world"))
    
    # Clean up after ourselves
    await client.shell_stop(first_connection_uuid)


if __name__ == "__main__":
    asyncio.run(main())

Tests

To run the test suite, you'll need to define the XPIPE_APIKEY env var. This will allow the two "log in with the ApiKey rather than Local method" tests to work. Here's the recommended method for running the tests with poetry:

cd /path/to/python_xpipe_client
poetry install
XPIPE_APIKEY=<api_key> poetry run pytest

Metadata

Release files for xpipe_client 0.1.26

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

Source distribution (sdist)

Source distribution for xpipe_client 0.1.26
File Size Uploaded
xpipe_client-0.1.26.tar.gz 5.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xpipe_client 0.1.26
File Interpreter ABI Platform
xpipe_client-0.1.26-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / xpipe_client-0.1.26.tar.gz

Download URL xpipe_client-0.1.26.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b45cf3ef082bac2b880e1002c3f37a5cc0bd31973e9eb015339de4f5329e9a46
BLAKE2b-256 checksum
How to use checksums
7baeef42045e9b5e46957e01c960007657bd76e826b72165dcd7dcf8e764c113
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.0 Windows/10

Release files / xpipe_client-0.1.26-py3-none-any.whl

Download URL xpipe_client-0.1.26-py3-none-any.whl
Size 6.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3cfe7511c1268254fb1fd1ac39ece8916715af662439dbc5dd9f2be75dcaefc
BLAKE2b-256 checksum
How to use checksums
9aff9df2c67f84b0fba703c29c49777a73ebb25e8e728a2468423c5a5f880bb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.0 Windows/10

Release history Release notifications | RSS feed

This release

0.1.26 This release

2 release files

0.1.25

2 release files

0.1.24

2 release files

0.1.22

2 release files

0.1.21

2 release files

0.1.20

2 release files

0.1.19

2 release files

0.1.18

2 release files

0.1.17

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

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