Connection package to a raspberry or any other machine using ssh, it simplifies the deployment scripts and monitoring.
- Prerequisites
- Install
- Install for developpement
- Usage in command line
- Usage as application
- Usage as module
- License
To use this program you need python 3.10, no support will be provided for previous versions.
You also need to install Putty and WinSCP
This package is not available on pypi at the moment. To install it, you need to download it from git as below.
pip install git+https://github.com/Dashstrom/raspinel
py -m raspinel
You need 6 versions of python for run test on every versions :
git clone https://github.com/Dashstrom/raspinel.git
cd raspinel
pip install -r requirements_dev.txt
For run test you can use tox
After downloading it you need to create a configuration file named .raspinel.yml
in one of the following places :
$HOME\.raspinel.yml
$MODULE_PATH\.raspinel.yml
$PWD\.raspinel.yml
It must contain the following structure where only the host is mandatory.
hostname: '192.168.0.X'
port: 22
username: 'pi'
password: 'YOUR_PASSWORD'
timemout: 2
You can also just use environment variables as :
export RASPINEL_HOSTNAME=192.168.0.X
export RASPINEL_PORT=22
export RASPINEL_PASSWORD=YOUR_PASSWORD
export RASPINEL_USERNAME=pi
export RASPINEL_TIMEOUT=2
You must of course replace the values given in the example by your own identifiers.
If all is well configure the following command should reply you hello world
.
py -m raspinel "echo 'hello world'"
The strength of this package is that it can be used as a command line tool, bellow are the supported command line functionality for the moment.
usage: py -m raspinel [-h] [-i] [-d src dest] [-u src dest] [commands ...]
Allows communication using ssh to get information, upload or download files or run commands.
Run without argument start program in GUI mode.
positional arguments:
commands commands to execute on remote
options:
-h, --help show this help message and exit
-i, --info show some information about remote
-d src dest, --download src dest
download file from remote using sftp
-u src dest, --upload src dest
upload file to remote using sftp
To launch the application, nothing could be simpler :
py -m raspinel
Here is a simple code that displays a hello world.
import sys
from raspinel import Client
if __name__ == "__main__":
# connect from env or files
with Client.resolve() as clt:
# send command
resp = clt.cmd("echo {}", "hello world")
# show outputs
print(resp.out)
print(resp.err)
# exit with the same exit code that command
sys.exit(resp.exit)
For more details or help use py -c "import raspinel;help(raspinel)"
raspinel is licensed under the terms of the GNU License (see the file LICENSE).