RASCSI/src/web/pi_cmds.py
Eric Helgeson 37f1166fd8
New Web Interface (#69)
* gitignore

* New Web Interface
Fixed spacing/tabs in easy install
Added migration check
Fix update web not actually updating

Migrating from https://github.com/erichelgeson/RaSCSI-web

* Allow user to select multiple types when creating images

* Show all devices even if nothing is attached.

* If attaching an iso to a cd device, dont detach, just insert

* UI feedback and restart rascsi service

* Check for any non-0 exit code for apache2 detection

* Pretty/informative 502

* Add confirms to some actions. Works in netscape 4.7

* Fix order of params for create_new_image

* Move non-route method to service

* Add method for getting logs

* Move settings to single file
add ability to mock commands for local dev
2020-12-30 19:39:32 -06:00

21 lines
637 B
Python

import subprocess
def rascsi_service(action):
# start/stop/restart
return subprocess.run(["sudo", "/bin/systemctl", action, "rascsi.service"]).returncode == 0
def reboot_pi():
return subprocess.run(["sudo", "reboot"]).returncode == 0
def shutdown_pi():
return subprocess.run(["sudo", "shutdown", "-h", "now"]).returncode == 0
def running_version():
ra_web_version = subprocess.run(["git", "rev-parse", "HEAD"], capture_output=True).stdout.decode("utf-8").strip()
pi_version = subprocess.run(["uname", "-a"], capture_output=True).stdout.decode("utf-8").strip()
return ra_web_version + " " + pi_version