Python 重新提交表单web.py时保持SSH过程

Python 重新提交表单web.py时保持SSH过程,python,ssh,web.py,paramiko,Python,Ssh,Web.py,Paramiko,我已经在web.py服务器中实现了一个SSH命令。当用户按下一个按钮时,一个SSH命令被发送到我的另一个Raspberry Pi,然后它播放一部电影。但是,每次窗体自行重置时,电影将停止播放 如何让Python执行子流程(SSH),即使表单已刷新 代码: 导入web 从web导入表单 导入操作系统 进口帕拉米科 cmd='cd/媒体/电影' remove_bars='sudo sh-c“TERM=linux setterm-前景黑色-清除>/dev/tty0”' ah='omxplayer-o

我已经在web.py服务器中实现了一个SSH命令。当用户按下一个按钮时,一个SSH命令被发送到我的另一个Raspberry Pi,然后它播放一部电影。但是,每次窗体自行重置时,电影将停止播放

如何让Python执行子流程(SSH),即使表单已刷新

代码:

导入web
从web导入表单
导入操作系统
进口帕拉米科
cmd='cd/媒体/电影'
remove_bars='sudo sh-c“TERM=linux setterm-前景黑色-清除>/dev/tty0”'

ah='omxplayer-o hdmi“American Hustle.mp4”我将/media/movies/添加到电影目录中,并且在
raise web之前
time.sleep(10)
。请参见其他('/')

import web
from web import form
import os
import paramiko

cmd = 'cd /media/movies'
remove_bars = 'sudo sh -c "TERM=linux setterm -foreground black -clear >/dev/tty0" '
ah = 'omxplayer -o hdmi "American Hustle.mp4" <fifo &'
nsm = 'omxplayer -o hdmi "Now You See Me.mp4" <fifo &'

def makeSSH():
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect('192.168.1.115', username='pi', password='raspberry')
    stdin, stdout, stderr = ssh.exec_command(cmd)
    stdin, stdout, stderr = ssh.exec_command(remove_bars)
    return ssh;


# define the pages
urls = ('/', 'index')
render = web.template.render('templates')

app = web.application(urls, globals())


my_form = form.Form(
        form.Button("btn", id="btnA", value="A", html="Now You See Me", class_="btnA")
)

class index:
    # GET is used when the page is first requested
    def GET(self):
        form = my_form()
        return render.index(form, "RPi Remote Control")

    # POST is called when a web form is submitted
    def POST(self):
        # get the data submitted from the web form
        userData = web.input()

        if userData.btn == "A":
            print "TEST 1"
            ssh = makeSSH()
            stdin, stdout, stderr = ssh.exec_command(nsm)
        else:
            print "WHAT IS GOING ON?"


        raise web.seeother('/')


if __name__ == '__main__':
    app.run()