Table of Contents

8.1 Python Scripting Basics

Connecting

ssh python-user@<device-ip>

Default password: python-user

The password can be changed with the standard passwd command after logging in.

Environment

The sandbox runs in a dedicated Linux user account (python-user) with a restricted shell environment:

Pre-installed packages

Package Purpose
requests HTTP client for calling APIs
fastapi Web framework for building REST services
uvicorn ASGI server for running FastAPI applications

Additional packages can be installed with pip install <package> provided the device has internet access.

Workspace

Scripts are stored in ~/workspace/. An example script is provided at startup:

~/workspace/example_api_call.py

This script fetches process data from the Pinebox API and prints the JSON response:

python workspace/example_api_call.py http://localhost:18080/0/device/status

Available Commands

Standard Unix utilities are available via symlinks in ~/bin:

ls, find, cat, grep, sed, awk, curl, wget, ping, ssh, scp, crontab, nano

Backup and Restore

The contents of ~/workspace/ and the list of installed pip packages (pip freeze) are included in the Pinebox user configuration backup. On restore, the workspace files are recovered and the package list is reinstalled automatically.

Internet access is required on the device at restore time for packages to be reinstalled.

Security Notes