python-varlink
A varlink implementation for Python.
python varlink installation
From pypi:
$ pip3 install --user varlink
With Fedora 28/rawhide:
$ sudo dnf install python3-varlink
Examples
See the tests directory.
$ python3 -m varlink.tests.test_orgexamplemore --varlink="unix:/tmp/test" &
[1] 6434
$ python -m varlink.cli help unix:/tmp/test/org.example.more
# Example Varlink service
interface org.example.more
# Enum, returning either start, progress or end
# progress: [0-100]
type State (
start: ?bool,
progress: ?int,
end: ?bool
)
# Returns the same string
method Ping(ping: string) -> (pong: string)
# Dummy progress method
# n: number of progress steps
method TestMore(n: int) -> (state: State)
# Stop serving
method StopServing() -> ()
# Something failed in TestMore
error TestMoreError (reason: string)
$ python -m varlink.cli call unix:/tmp/test/org.example.more.Ping '{ "ping": "Ping"}'
{
"pong": "Ping"
}
$ fg
python3 -m varlink.tests.test_orgexamplemore --varlink="unix:/tmp/test"
^C
$ python3 -m varlink.tests.test_orgexamplemore --client -A 'python3 -m varlink.tests.test_orgexamplemore --varlink=$VARLINK_ADDRESS'
Connecting to unix:/tmp/tmppxrbqk9p/4927
Listening on /tmp/tmppxrbqk9p/4927
--- Start ---
Progress: 0
Progress: 10
Progress: 20
Progress: 30
Progress: 40
Progress: 50
Progress: 60
Ping: Test
Progress: 70
Ping: Test
Progress: 80
Ping: Test
Progress: 90
Ping: Test
Progress: 100
Ping: Test
--- End ---
$ PYTHONPATH=$(pwd) python3 ./varlink/tests/test_orgexamplemore.py
Connecting to unix:/tmp/tmp7n6zc67d/5257
Listening on /tmp/tmp7n6zc67d/5257
--- Start ---
Progress: 0
Progress: 10
Progress: 20
Progress: 30
Progress: 40
Progress: 50
Progress: 60
Ping: Test
Progress: 70
Ping: Test
Progress: 80
Ping: Test
Progress: 90
Ping: Test
Progress: 100
Ping: Test
--- End ---
$ python3 -m varlink.tests.test_orgexamplemore --varlink="unix:/tmp/test" &
Listening on /tmp/test
[1] 6434
python3 -m varlink.tests.test_orgexamplemore --client --varlink="unix:/tmp/test"
Connecting to unix:/tmp/test
Ping: Test
--- Start ---
Progress: 0
Progress: 10
Progress: 20
Progress: 30
Progress: 40
Progress: 50
Progress: 60
Ping: Test
Progress: 70
Ping: Test
Progress: 80
Ping: Test
Progress: 90
Ping: Test
Progress: 100
Ping: Test
--- End ---
$ python3 -m varlink.cli call --more unix:/tmp/test/org.example.more.TestMore '{ "n": 10 }'
{'state': {'start': True}}
{'state': {'progress': 0}}
{'state': {'progress': 10}}
{'state': {'progress': 20}}
{'state': {'progress': 30}}
{'state': {'progress': 40}}
{'state': {'progress': 50}}
{'state': {'progress': 60}}
{'state': {'progress': 70}}
{'state': {'progress': 80}}
{'state': {'progress': 90}}
{'state': {'progress': 100}}
{'state': {'end': True}}
$ fg
python3 -m varlink.tests.test_orgexamplemore --varlink="unix:/tmp/test"
^C
You can also start the clients and server with URLs following the varlink URL standard with unix: and tcp:.
E.g.
- unix:@anonuds
- unix:/run/myserver/socketfile
- tcp:127.0.0.1:12345
- tcp:[::1]:12345
Activation Mode
Activation mode starts the service to connect to and passes the socket via socket activation.
The VARLINK_ADDRESS environment variable contains the varlink address URI.
$ python3 -m varlink.cli --activate 'python3 -m varlink.tests.test_orgexamplemore --varlink=$VARLINK_ADDRESS' call org.example.more.Ping '{ "ping": "Ping"}'
Listening on @00352
{'pong': 'Ping'}
Bridge Mode
Bridge mode allows to tunnel to a remote point via stdin/stdout and call a method.
Running varlink bridge allows to connect stdio to the host services via org.varlink.resolver interface resolving.
# python3 -m varlink.cli -b "ssh host.example.org varlink bridge" call com.redhat.machine.GetInfo '{}'
{
"hostname": "host.example.org",
"system": {
"id": "fedora",
"kernel_version": "4.18.0-0.rc5.git1.2.fc29.x86_64",
"name": "Fedora",
"version": "29"
},
"virtualization": {
"name": "none"
}
}
Varlink Certification Server
$ python3 -m varlink.tests.test_certification --varlink=tcp:127.0.0.1:12345
Varlink Certification Client
$ python3 -m varlink.tests.test_certification --varlink=tcp:127.0.0.1:12345 --client
Metadata
Release files for varlink 31.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| varlink-31.0.0.tar.gz | 44.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| varlink-31.0.0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details |
Total release size: 84.4 kB
Release files / varlink-31.0.0.tar.gz
| Download URL | varlink-31.0.0.tar.gz |
|---|---|
| Size | 44.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4070cb2c250f459bcea88c99bb08203d65e4f41241a4f68942969f25123b0a31
|
|
BLAKE2b-256 checksum How to use checksums |
e690172069117da79f1b62a29417dac7c7e544dda82bfb28af18167d1fb3aaaf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Release files / varlink-31.0.0-py2.py3-none-any.whl
| Download URL | varlink-31.0.0-py2.py3-none-any.whl |
|---|---|
| Size | 39.8 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
0d0629e5ca7e629f79ed84dc5a4f29e04f3cc83b24641528e91a41fa158e58e9
|
|
BLAKE2b-256 checksum How to use checksums |
e6ce7dade08126c0599865d1f955b21dad2b11df604b7678a37689559ac56d20
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
|
Security for varlink 31.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.