diff options
author | Britney Fransen <brfransen@gmail.com> | 2014-10-09 22:51:53 (GMT) |
---|---|---|
committer | Britney Fransen <brfransen@gmail.com> | 2014-10-09 22:51:53 (GMT) |
commit | 54fb52252c8067c8b2d5b8c10fab5bc299db93cb (patch) | |
tree | 5fcf9da9ede63fded7643d4360e061b7fed11dbe /abs/core/supplemental-web | |
parent | ceaa14a9a98c061e6a046f0d21af059436766e9c (diff) | |
download | linhes_pkgbuild-54fb52252c8067c8b2d5b8c10fab5bc299db93cb.zip linhes_pkgbuild-54fb52252c8067c8b2d5b8c10fab5bc299db93cb.tar.gz linhes_pkgbuild-54fb52252c8067c8b2d5b8c10fab5bc299db93cb.tar.bz2 |
supplemental-web: process.py: dont' run the loader for some actions.
Diffstat (limited to 'abs/core/supplemental-web')
-rw-r--r-- | abs/core/supplemental-web/PKGBUILD | 2 | ||||
-rwxr-xr-x | abs/core/supplemental-web/contents/process.py | 106 |
2 files changed, 66 insertions, 42 deletions
diff --git a/abs/core/supplemental-web/PKGBUILD b/abs/core/supplemental-web/PKGBUILD index d4a6513..603b9cf 100644 --- a/abs/core/supplemental-web/PKGBUILD +++ b/abs/core/supplemental-web/PKGBUILD @@ -1,7 +1,7 @@ pkgbase=supplemental-web pkgname=('supplemental-web' 'supplemental-web-slave') pkgver=8.2 -pkgrel=4 +pkgrel=5 arch=('i686' 'x86_64') license=('GPL') backup=('data/srv/httpd/cgi/extra.cfg.txt') diff --git a/abs/core/supplemental-web/contents/process.py b/abs/core/supplemental-web/contents/process.py index d624f60..60714ee 100755 --- a/abs/core/supplemental-web/contents/process.py +++ b/abs/core/supplemental-web/contents/process.py @@ -17,14 +17,6 @@ def cgiprint(inline=''): sys.stdout.flush() contentheader = 'Content-Type: text/html' -thepage = '''<html><head> -<title>%s</title> -</head><body> -%s -</body></html> -''' -h1 = '<h1>%s</h1>' - def getform(theform, valuelist, notpresent='', nolist=False): """ This function, given a CGI form as a @@ -127,19 +119,14 @@ def go_download_backup(dl_file): print str return results - def go_restore(restorefile,myhost,prestore): myhostname = socket.gethostname() psc = '' if prestore == "on": psc = "partial" - if myhostname.strip() == myhost.strip(): command="sudo /usr/LH/bin/lh_system_restore_job %s %s" %(restorefile , psc) - - - else: #this should never execute sshcmd="ssh -o StrictHostKeyChecking=no -o ConnectTimeout=1 -i /data/srv/.nobody_ssh/id_dsa mythtv@" @@ -162,16 +149,13 @@ def go_upload(up_file): line = '''The backup has been uploaded and is now available for restore. To restore from the file, check "Restore database" then select the file from the drop down menu''' - results.append(line) command2="sleep 1; sudo -u nobody /home/xymon/server/ext/hbnotes.py" os.popen(command2,'r') - return results - def go_optimize(myhost): #myhostname = socket.gethostname() #if myhostname.strip() == myhost.strip(): @@ -191,14 +175,12 @@ def go_update(myhost,update_type): return results def go_updateall(allupdate_type): - cmd=" sudo /usr/bin/update_system_all " cmd+=allupdate_type command= cmd + " 2>&1 " results=os.popen(command,'r') return results - def go_shutdown(myhost): myhostname = socket.gethostname() message="Shutdown from MBE" @@ -217,7 +199,7 @@ def go_shutdownall(): db = MySQLdb.connect(host="localhost", user="mythtv", passwd="mythtv", db="mythconverg") # create a cursor cursor = db.cursor() - # execute SQL statement + # execute SQL statement myhostname = socket.gethostname() results=["Sent shutdown command to: \n "] cursor.execute("SELECT distinct(hostname) from settings where not hostname = %s ; ",(myhostname)) @@ -265,10 +247,25 @@ def go_restart_mbe_local(): return results +mainpage = ''' +<html> + <head> + <style type="text/css">@import "/frame.css";</style> + <meta http-equiv="cache-control" content="max-age=0"> + <meta http-equiv="cache-control" content="no-cache"> + <meta http-equiv="expires" content="0"> + <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT"> + <meta http-equiv="pragma" content="no-cache"> + <title>LinHES</title> + </head> + <body> + %s + </body> +</html> +''' -mainpage = '''<title>%s</title>''' -loading = ''' +loadingpage = ''' <html> <head> <style type="text/css">@import "/frame.css";</style> @@ -280,13 +277,12 @@ loading = ''' <meta http-equiv="pragma" content="no-cache"> <title>LinHES</title> </head> - <body> <div id="header"> %s </div> <div id="container"> - <br> <br> + <br><br> <h3>Working. Please Wait...</h3> <br><br> <div> @@ -306,20 +302,20 @@ loading = ''' </script> ''' + error = ''' <h1>Error</h1> <h2>No Form Submission Was Received</h2>''' + result = ''' <h1>%s of %s</h1> ''' + possible_parameters = ['param1', 'param2', 'param3', 'param4','hiddenparam','param5','param6','param7','uFile','param8'] if __name__ == '__main__': - #cgiprint(contentheader) # content header - #cgiprint() # finish headers with blank line - theform = cgi.FieldStorage() #print theform formdict = getform(theform, possible_parameters) @@ -348,50 +344,78 @@ if __name__ == '__main__': prestore = "off" body = result % (radio, hidden) - - cgiprint(contentheader) # content header - cgiprint() # finish headers with blank line - print loading % body - #print mainpage % body selection=radio myhost=hidden.lower() if selection == "Restore": mylogfile=go_restore(name,myhost,prestore) + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print mainpage % body elif selection == "Backup": + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print loadingpage % body mylogfile=go_backup(myhost) elif selection == "Dbackup": mylogfile=go_download_backup(dl_file) + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print mainpage % body elif selection == "Update": + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print loadingpage % body mylogfile=go_update(myhost,update_type) elif selection == "Shutdown": mylogfile=go_shutdown(myhost) + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print mainpage % body elif selection == "Reboot": mylogfile=go_reboot(myhost) + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print mainpage % body elif selection == "Optimize": + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print loadingpage % body mylogfile=go_optimize(myhost) elif selection == "WOL": + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print loadingpage % body mylogfile=go_wake(myhost) elif selection == "UpdateAll": mylogfile=go_updateall(all_update_type) + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print mainpage % body elif selection == "ShutdownAll": mylogfile=go_shutdownall() + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print mainpage % body elif selection == "Kill": mylogfile=go_kill(myhost,kill_type) + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print mainpage % body elif selection == "Upload": mylogfile = go_upload(up_file) + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print mainpage % body elif selection == "RestartMBE": mylogfile = go_restart_mbe_local() + cgiprint(contentheader) # content header + cgiprint() # finish headers with blank line + print mainpage % body - #cgiprint(contentheader) # content header cgiprint() # finish headers with blank line - #print mainpage % body - #box=''' </br> </br> - #<div style="border: 1px solid #aaa; width:700px; height:700px; overflow:auto; color:#FFF;text-align:left;"> - #<code id="box" style="display: block; height: 700px; width: 700px; overflow: auto;"> - #''' - box='''<br> <br> + box='''<br><br> <div id="resultbox" > ''' @@ -407,14 +431,14 @@ if __name__ == '__main__': var objDiv = document.getElementById("resultbox"); objDiv.scrollTop = objDiv.scrollHeight; </script> - ''' + ''' print box for line in mylogfile: - print line + '</br> \r\n' + print line + '<br> \r\n' print endbox - print "</br></br>" + print "<br><br>" #print '<a href=', oldurl, ' > Back </a> ' s='<a href="%s"><img src="back.png"></a>' %oldurl print s |