Run shell command as subprocess
This commit is contained in:
10
rc/rc.py
10
rc/rc.py
@@ -14,7 +14,7 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from bottle import post, route, request, template, static_file, run
|
from bottle import post, route, request, template, static_file, run
|
||||||
import os
|
import os, subprocess
|
||||||
|
|
||||||
@route('/')
|
@route('/')
|
||||||
@route('/', method='POST')
|
@route('/', method='POST')
|
||||||
@@ -23,16 +23,16 @@ def remote_control():
|
|||||||
free_home = "%.2f" % float((st_home.f_bavail * st_home.f_frsize)/1.073741824e9)
|
free_home = "%.2f" % float((st_home.f_bavail * st_home.f_frsize)/1.073741824e9)
|
||||||
|
|
||||||
if (request.POST.get("cardbackup")):
|
if (request.POST.get("cardbackup")):
|
||||||
os.system("sudo /home/pi/little-backup-box/scripts/card-backup.sh")
|
process = subprocess.Popen("sudo /home/pi/little-backup-box/scripts/card-backup.sh", shell=True)
|
||||||
return ('Backup started. You can close this page.')
|
return ('Backup started. You can close this page.')
|
||||||
if (request.POST.get("camerabackup")):
|
if (request.POST.get("camerabackup")):
|
||||||
os.system("sudo /home/pi/little-backup-box/scripts/camera-backup.sh")
|
process = subprocess.Popen("sudo /home/pi/little-backup-box/scripts/camera-backup.sh", shell=True)
|
||||||
return ('Backup started. You can close this page.')
|
return ('Backup started. You can close this page.')
|
||||||
if (request.POST.get("devicebackup")):
|
if (request.POST.get("devicebackup")):
|
||||||
os.system("sudo /home/pi/little-backup-box/scripts/device-backup.sh")
|
process = subprocess.Popen("sudo /home/pi/little-backup-box/scripts/device-backup.sh", shell=True)
|
||||||
return ('Transfer started. You can close this page.')
|
return ('Transfer started. You can close this page.')
|
||||||
if (request.POST.get("shutdown")):
|
if (request.POST.get("shutdown")):
|
||||||
os.system("sudo shutdown -h now")
|
process = subprocess.Popen("sudo shutdown -h now", shell=True)
|
||||||
return ('Shutdown request sent. You can close this page.')
|
return ('Shutdown request sent. You can close this page.')
|
||||||
return template('rc.tpl', freespace_home=free_home)
|
return template('rc.tpl', freespace_home=free_home)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user