From 54fb52252c8067c8b2d5b8c10fab5bc299db93cb Mon Sep 17 00:00:00 2001 From: Britney Fransen Date: Thu, 9 Oct 2014 22:51:53 +0000 Subject: supplemental-web: process.py: dont' run the loader for some actions. --- abs/core/supplemental-web/PKGBUILD | 2 +- 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 = ''' -%s - -%s - -''' -h1 = '

%s

' - 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 = ''' + + + + + + + + + LinHES + + + %s + + +''' -mainpage = '''%s''' -loading = ''' +loadingpage = ''' @@ -280,13 +277,12 @@ loading = ''' LinHES -
-

+

Working. Please Wait...



@@ -306,20 +302,20 @@ loading = ''' ''' + error = '''

Error

No Form Submission Was Received

''' + result = '''

%s of %s

''' + 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='''

- #
- # - #''' - box='''

+ box='''

''' @@ -407,14 +431,14 @@ if __name__ == '__main__': var objDiv = document.getElementById("resultbox"); objDiv.scrollTop = objDiv.scrollHeight; - ''' + ''' print box for line in mylogfile: - print line + '
\r\n' + print line + '
\r\n' print endbox - print "

" + print "

" #print ' Back ' s='' %oldurl print s -- cgit v0.12