An unofficial wrapper for Engineer Man's Piston API
Project description
Pistonpy
Pistonpy is an API wrapper for the Piston code execution engine by Engineer Man.
Key Features
- Simple modern and efficient Pythonic API using the
requests
lib. - Supports application integration and CLI usage.
Requirements
Python 3.8+
Installing
To install the library, run the following commands:
# Linux/MacOS
python3 -m pip install -U pistonpy
# Windows
py -3 -m pip install -U pistonpy
Usage
from pistonpy import PistonApp
# Initialize the client.
piston = PistonApp()
my_code = "print('This code ran from app.py itself!')"
output = piston.run(language="python", version="3.10.0", code=my_code)
print(output)
This gives the output:
{'language': 'python', 'version': '3.10.0', 'run': {'stdout': 'This code ran from app.py itself!\n', 'stderr': '', 'code': 0, 'signal': None, 'output': 'This code ran from app.py itself!\n'}}
run_file = piston.run(language="python", files=['test.py']) # version is optional. files even if it maybe only one must be given as lists.
print(run_file)
This gives the same output,
{'language': 'python', 'version': '3.10.0', 'run': {'stdout': 'The code ran from test.py\n', 'stderr': '', 'code': 0, 'signal': None, 'output': 'The code ran from test.py\n'}}
# You cannot provide both code and files in a single PistonAPP().run() instance.
# For running multiple files (For now it ONLY supports multiple python files)
multiple_files = piston.run(language="python", version="3.10.0", files=['test.py', 'test_two.py'])
print(multiple_files)
Sadly, the output for multiple files are provided all-together. This will be fixed in the upcoming updates. The above statement will output to:
{'language': 'python', 'version': '3.10.0', 'run': {'stdout': 'The code ran from test.py\nthis is test 2\n', 'stderr': '', 'code': 0, 'signal': None, 'output': 'The code ran from test.py\nthis is test 2\n'}}
print(piston.languages) # Prints the available languages along with their version.
print(piston.aliases) # Prints the available languages along with their alias/aliases.
print(piston.raw) # Prints the raw data without any formatting done.
License
This project is distributed under the MIT license.
Piston
For visiting Piston's github repository, click here.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pistonpy-0.0.3.tar.gz
.
File metadata
- Download URL: pistonpy-0.0.3.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f187f0d4c21e63b88bd47f9e068e6bdddd575ed131e0f5c72281f7fc1f28d1c |
|
MD5 | db1eb03790a419dd751ca648ed503e3b |
|
BLAKE2b-256 | 06cccdf7518039252c20117151c9001de2061640b3b340ca4e45c5e07e78ebe2 |
File details
Details for the file pistonpy-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pistonpy-0.0.3-py3-none-any.whl
- Upload date:
- Size: 9.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4c84d363faac227d1a6a9c70f4e66dd0cd38da0fc215e0dbe91d09b0e4a7cdd |
|
MD5 | 6bbed2921fa3c4704f434dff95744852 |
|
BLAKE2b-256 | 86c573ec14c22ebd960126e60a45d26fe3e0a3f33981e437161e8b047bc77cf7 |