Skip to main content

Library to make command calls from other application of Python more easy

Project description

PyEasyEmbed

PyEasyEmbed is a little framework to integrate python code into other applications using shell commands. Instead of multiple arguments, a EasyEmbed app expects one JSON-Object to deal with. PyEasyEmbed is written in pure Python3.

Usage

PyEasyEmbed uses a Server object which dispatches commands.

import EasyEmbed as EE

# The version number is the number of your application which can be used by your main app to determine if the embedded app is compatible
ser = EE.CommandServer(version = "0.1")

# A command responder which returns the input JSON Object, the name of the command is determined by the name of the function
@ser.command
def echo(data):
    return data

# Call the execute function to dispatch the input to the available commands
ser.execute()

Command structure

A PyEasyEmbed command has always one or two arguments. The first is the name of the called command, the second is a JSON-Object which is parsed and deliverd as a parameter to the command function. Depending on your shell interface you may need to escape quotes. If no JSON-Object is provided, the data paramter will be None.

Example call

python example.py echo "{\"hello\":\"world\"}"

The command server has a standard info command which prints the version number of your app, the python version running etc.

Response structure

To the command call from above the response would be the following:

{
    "status": 0,
    "response": {"hello":"world"}
}

In case an exception occured during the command function, the following is returned:

{
    "status": 1,
    "message": "Exception occured while executing command!",
    "exception": Traceback String
}

In case the command is not defined:

{
    "status": -1,
    "message": "Command does not exist!"
}

In case the JSON-Object could not be parsed:

{
    "status": -3,
    "message": "JSON data could not be parsed!"
}

Project details


Download files

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

Source Distribution

PyEasyEmbed-0.1.2.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

PyEasyEmbed-0.1.2-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file PyEasyEmbed-0.1.2.tar.gz.

File metadata

  • Download URL: PyEasyEmbed-0.1.2.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0

File hashes

Hashes for PyEasyEmbed-0.1.2.tar.gz
Algorithm Hash digest
SHA256 973e58566d4d9a4e7e9745f211849ab6c5b3dc62e7399bfa6a87e0d051da69ec
MD5 169387191df107167fc2d8edc3c76752
BLAKE2b-256 8ff97d2d57f072d4d6d4de5251e86f2fdff26555270c2bf2efb9117e56e4c6ad

See more details on using hashes here.

File details

Details for the file PyEasyEmbed-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: PyEasyEmbed-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.9.0

File hashes

Hashes for PyEasyEmbed-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 36a069e90b9bad6c5700ea6a395ab0d5a0aaa369903996189f04943afb2e6d7a
MD5 8fac84832cb603ad552a7a9b0d40127e
BLAKE2b-256 d3bc6b80c58223b00b4bea0195cc999b4fdec7e5a2bcba333b8628ee7dd797d7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page