]> git.parisson.com Git - telecaster-cgi.git/commitdiff
try to fix first page reload.. :( cleanup
authoryomguy <yomguy@parisson.com>
Fri, 1 Oct 2010 13:21:21 +0000 (13:21 +0000)
committeryomguy <yomguy@parisson.com>
Fri, 1 Oct 2010 13:21:21 +0000 (13:21 +0000)
station.py
telecaster.py
webview.py

index b30be64424cc5812b361288337132237c93bc5a1..a0bce8493e06bbae31df401b70ce9863dfb80b43 100644 (file)
@@ -38,7 +38,6 @@
 
 import os
 import pwd
-import shutil
 import datetime
 import time
 import urllib
index 811b95764611b98fdeef96eef2238fc1ef2b7857..ede25fa94f74fa2c8328ad719b90c75faa9e3ea0 100755 (executable)
@@ -68,13 +68,25 @@ class TeleCaster:
         if not os.path.exists(self.user_dir):
             os.makedirs(self.user_dir)
         self.lock_file = self.user_dir + os.sep + 'telecaster.lock'
-        self.form = WebView(self.conf, version)
+
+    def transition_head(self):
+        html_file = open('telecaster_starting_head.html', 'r')
+        html = html_file.read()
+        html_file.close()
+        return html
+
+    def transition_foot(self):
+        html_file = open('telecaster_starting_foot.html', 'r')
+        html = html_file.read()
+        html_file.close()
+        return html
 
     def main(self):
         edcast_pid = get_pid('edcast_jack', self.uid)
         deefuzzer_pid = get_pid('/usr/bin/deefuzzer '+self.user_dir+os.sep+'deefuzzer.xml', self.uid)
         writing = edcast_pid != []
         casting = deefuzzer_pid != []
+        self.form = WebView(self.conf, version)
 
         if deefuzzer_pid == [] and self.form.has_key("action") and \
             self.form.has_key("department") and self.form.has_key("conference") and \
@@ -88,16 +100,20 @@ class TeleCaster:
                         'professor': self.form.getfirst("professor"),
                         'comment': self.form.getfirst("comment")}
 
+            self.form = 0
+            #print "Content-Type: text/html\n\n"
+            #print self.transition_head()
             s = Station(self.conf_file, self.conference_dict, self.lock_file)
             s.start()
+#            time.sleep(1)
+            #print self.transition_foot()
             self.logger.write_info('starting')
-            time.sleep(2)
             self.main()
 
         elif deefuzzer_pid != [] and os.path.exists(self.lock_file) and not self.form.has_key("action"):
             self.conference_dict = get_conference_from_lock(self.lock_file)
             self.form.stop_form(self.conference_dict, writing, casting)
-            self.logger.write_info('page stop')
+            self.logger.write_info('started')
 
         elif deefuzzer_pid and self.form.has_key("action") and self.form["action"].value == "stop":
             if os.path.exists(self.lock_file):
@@ -110,12 +126,13 @@ class TeleCaster:
 
         elif deefuzzer_pid == []:
             self.form.start_form(writing, casting)
-            self.logger.write_info('page start')
-
+            self.logger.write_info('stopped')
+    
 
 conf_file = '/etc/telecaster/telecaster.xml'
 
 if __name__ == '__main__':
     t = TeleCaster(conf_file)
     t.main()
 
index 215934fa87a923bb64bc8ef007eaae853d425e8e..825f6f86dbfa710cd63a8fd2537d31c51bb6d523 100644 (file)
 
 import os
 import cgi
-import cgitb
-import shutil
+#import cgitb
 import datetime
 import time
-import codecs
 import string
-import signal
-import unicodedata
 from tools import *
 from cgi import FieldStorage
-cgitb.enable()
+#cgitb.enable()
 
 class WebView(FieldStorage):
     """Gives the web CGI frontend"""
@@ -92,7 +88,7 @@ class WebView(FieldStorage):
 
     def header(self):
         # Required header that tells the browser how to render the HTML.
-        print "Content-Type: text/html\n"
+        print "Content-Type: text/html\n\n"
         print "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">"
         print "<HTML>"
         print "<HEAD>"
@@ -217,7 +213,7 @@ class WebView(FieldStorage):
         else:
             print "<button class=\"negative\"><img src=\"img/drive_error.png\" alt=\"\">NOT Recording !</button>"
         print "</div></td>"
-        print "<TD> </TD>"
+        print "<td></td>"
         print "<td><div class=\"buttons\">"
         if self.casting:
             print "<button class=\"positive\"><img src=\"img/transmit_add.png\" alt=\"\">Diffusing...</button>"
@@ -238,19 +234,20 @@ class WebView(FieldStorage):
         self.javascript()
         self.sub_header()
         self.hardware_data()
-        print "<form method=\"POST\" action=\"telecaster.py\" name=\"formulaire_start\">"
+        
+        print "<form method=\"POST\" action=\"telecaster.py\" name=\"formulaire\">"
         print "<div class=\"main\">"
         print "<table class=\"form\">"
         print "<TR><TH align=\"left\">Titre</TH><TD> : </TD><TD>"+self.title+"</TD></TR>"
         print "<TR><TH align=\"left\">D&eacute;partement</TH><TD> : </TD>"
         print "<TD><select name=\"department\" onChange=\"choix(this.form)\">"
-        print "<option value=\"unknown\">...........Choisissez un d&eacute;partement...........</option>"
+        print "<option selected=\"\">...........Choisissez un d&eacute;partement...........</option>"
         for department in self.departments:
             print "<option value=\""+department['name']+"\">"+department['name']+"</option>"
         print "</select></TD></TR>"
         print "<TR><TH align=\"left\">Conf&eacute;rence</TH><TD> : </TD>"
         print "<TD><select name=\"conference\">"
-        print "<option value=\"unknown\">...........Choisissez une conf&eacute;rence...........</option>"
+        print "<option selected=\"\">...........Choisissez une conf&eacute;rence...........</option>"
         for i in range(1,self.conference_nb_max):
             print "<option></option>"
         print "</select></TD></TR>"
@@ -289,8 +286,11 @@ class WebView(FieldStorage):
         
         self.header()
         self.sub_header()
+        
+        print "<form method=\"POST\" action=\"telecaster.py\" name=\"formulaire\">"
+        
         self.hardware_data()
-        print "<form method=\"POST\" action=\"telecaster.py\" name=\"formulaire_stop\">"
+        
         print "<div class=\"main\">"
         print "<table class=\"form\">"
         print "<TR><TH align=\"left\">Titre</TH><TD> : </TD><TD>"+self.title+"</TD></TR>"