Skip to main content

PyKQML

PyKQML is an implementation of KQML messaging in Python.

Installation

PyKQML can be installed as

pip install pykqml

Note that releases of PyKQML up to 0.5 work in Python 2 only, whereas releases above and including 1.0 work in Python 3 only.

To install for Python 2, use:

pip install pykqml==0.5

To install for Python 3 (or force an upgrade to a compatible version), use

pip install "pykqml>0.5"

Usage

PyKQML implements the following KQML classes, which allow constructing and manipulating KQML messages programmatically:

KQMLToken
KQMLString
KQMLQuotation
KQMLList
KQMLPerformative
KQMLReader
KQMLDispatcher
KQMLModule

You can import KQML classes as, for instance,

from kqml import KQMLList

You can create a new KQML messaging agent in the context of the TRIPS system as

from kqml import KQMLModule

class MyAgent(KQMLModule):
    name = "MyAgent" # This is the name of the agent to register with

    def __init__(self, **kwargs):
        # Call the parent class' constructor which sends a registration
        # message, setting the agent's name to be recognized by the
        # Facilitator.
        super(MyAgent, self).__init__(name=self.name, **kwargs)

        # Subscribe to REQUESTs of interest. The list will change
        # depending on the role of the agent
        for req in ('what-next', 'commit', 'evaluate'):
            self.subscribe_request(req)

        # Subscribe to TELLs of interest if needed. This list will change
        # depending on the role of the agent
        for tell in ('log-speechact', ):
            self.subscribe_tell(tell)

        # Now signal that the agent is ready to receive messages
        self.ready()

        # Finally, start the listener for incoming messages
        self.start()


    def receive_request(self, msg, content):
        # First, figure out what kind of request this is
        task = content.head().upper()
        # Here you typically decide what to do based on the
        # type of request.

        # Construct reply message's content
        reply_content = KQMLList()
        # Set whatever needs to be set in the reply content

        # Finally, wrap the content in a message and reply
        reply_msg = KQMLPerformative('reply')
        reply_msg.set('content', reply_content)
        self.reply(msg, reply_msg)

Testing

You can run all tests by running nosetests in the top level folder.

Metadata

Release files for pykqml 1.3

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

Source distribution (sdist)

Source distribution for pykqml 1.3
File Size Uploaded
pykqml-1.3.tar.gz 15.3 kB Details

Built distribution (wheel)

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

Total release size: 31.7 kB

Release files / pykqml-1.3.tar.gz

Download URL pykqml-1.3.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
dd365413f6776dd55c87c1fb1756a49d39e22d087c6b92543713e51d120e3ea4
BLAKE2b-256 checksum
How to use checksums
3b4395ce856e12cf073a9bc7f2ee87ad532c4c0f95d7dd07aaba0ac9063c554d
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/46.1.3 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.7

Release files / pykqml-1.3-py3-none-any.whl

Download URL pykqml-1.3-py3-none-any.whl
Size 16.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
95cb17c731f9f3881f7163b9c678617c2d3ddf0bf74f2ed1985b04708873b609
BLAKE2b-256 checksum
How to use checksums
22c616d2b35a8b60eb44c0fde61a419f789e2664fcc2d718d181adc480132d52
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/46.1.3 requests-toolbelt/0.9.1 tqdm/4.40.1 CPython/3.7.7

Release history Release notifications | RSS feed

This release

1.3 This release

2 release files

1.2

2 release files

1.1

2 release files

1.0

1 release file

0.5

1 release file

0.4

1 release file

0.1

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