REST server that enables arbitrary commands to be scheduled, and for their status to be retrieved.
For safety, it is designed to permit specific commands only. Define these in src/rest_cmd_server/command_defs.py
CommandDefs = {"sleep_5s_linux": os.path.dirname(os.getcwd()) + "/test/sleep.sh",
"sleep_5s_windows": os.path.dirname(os.getcwd()) + "\\test\\sleep.bat",
"ffmpeg_linux": "/usr/bin/ffmpeg"}
cd src
python3 main.py
cd test
python3 -m unittest rest_cmd_server__test.py -v
curl -X POST http://127.0.0.1:8080/job \
-H 'Content-Type: application/json' \
-d '{
"jobName": "framecount",
"command": "ffmpeg_linux",
"parameters": [
"-y",
"-v", "panic", "-stats",
"-i", "/mnt/c/source/test_video.mxf",
"-map", "0:v:0", "-c", "copy", "-f", "null", "-y", "-"
]
}'
curl -X POST http://127.0.0.1:8080/job \
-H 'Content-Type: application/json' \
-d '{
"jobName": "transcode",
"command": "ffmpeg_linux",
"parameters": [
"-y",
"-v", "info", "-progress", "pipe:1",
"-i", "/mnt/c/source/test_video.mxf",
"-vcodec", "libx264",
"/mnt/y/src/rest_cmd_server/test_video.mp4"
]
}'
curl -X POST http://127.0.0.1:8080/job \
-H 'Content-Type: application/json' \
-d '{
"jobName": "SleepLinux",
"command": "sleep_5s_linux",
"parameters": []
}'
curl -X GET http://127.0.0.1:8080/job/8888/cancel
curl -X GET 'http://127.0.0.1:8080/job/status'
curl -X GET 'http://127.0.0.1:8080/job/active'
curl -X GET 'http://127.0.0.1:8080/job/7806349662268392/status'
Managed via Pipenv:
pipenv install
Will create a Python virtual environment with dependencies specified in the Pipfile
To active it, simply enter:
pipenv shell