]> git.parisson.com Git - telecaster-client.git/commitdiff
Add nice buttons, try to fix refresh, cleanup
authoryomguy <>
Mon, 20 Oct 2008 22:38:51 +0000 (22:38 +0000)
committeryomguy <>
Mon, 20 Oct 2008 22:38:51 +0000 (22:38 +0000)
27 files changed:
css/telecaster.css
etc/telecaster_mp3.cfg
img/accept.png [new file with mode: 0644]
img/bin.png [new file with mode: 0644]
img/cancel.png [new file with mode: 0644]
img/control_pause_blue.png [new file with mode: 0644]
img/control_play_blue.png [new file with mode: 0644]
img/control_stop.png [new file with mode: 0644]
img/control_stop_blue.png [new file with mode: 0644]
img/drive_add.png [new file with mode: 0644]
img/drive_burn.png [new file with mode: 0644]
img/drive_delete.png [new file with mode: 0644]
img/drive_error.png [new file with mode: 0644]
img/folder_go.png [new file with mode: 0644]
img/folder_link.png [new file with mode: 0644]
img/ipod_cast.png [new file with mode: 0644]
img/stop.png [new file with mode: 0644]
img/tick.png [new file with mode: 0644]
img/transmit.png [new file with mode: 0644]
img/transmit_add.png [new file with mode: 0644]
img/transmit_blue.png [new file with mode: 0644]
img/transmit_delete.png [new file with mode: 0644]
img/transmit_edit.png [new file with mode: 0644]
img/transmit_error.png [new file with mode: 0644]
img/transmit_go.png [new file with mode: 0644]
img/tux.png [new file with mode: 0644]
telecaster.py

index f0a874a1c82bf7d4f073f09d4e4987602906ece0..d66634d5441d21ec115854afa21bf4fd308740ed 100644 (file)
@@ -30,6 +30,7 @@ div.tools { background-color: #030250;
            border: 1px solid #FFFFFF;
            padding:0.5em;
            margin: 0;
+        height: 32px;
 }
 
 div.colophon { background-color: #FFFFFF;
@@ -66,3 +67,88 @@ div.form { background-color: #FFFFFF;
        margin: 0;
 }
 
+/* BUTTONS */
+
+.buttons a, .buttons button{
+    display:block;
+    float:left;
+    margin:0 7px 0 0;
+    background-color:#f5f5f5;
+    border:1px solid #dedede;
+    border-top:1px solid #eee;
+    border-left:1px solid #eee;
+
+    font-family:"Lucida Grande", Tahoma, Arial, Verdana, sans-serif;
+    font-size:100%;
+    line-height:130%;
+    text-decoration:none;
+    font-weight:bold;
+    color:#565656;
+    cursor:pointer;
+    padding:5px 10px 6px 7px; /* Links */
+}
+.buttons button{
+    width:auto;
+    overflow:visible;
+    padding:4px 10px 3px 7px; /* IE6 */
+}
+.buttons button[type]{
+    padding:5px 10px 5px 7px; /* Firefox */
+    line-height:17px; /* Safari */
+}
+*:first-child+html button[type]{
+    padding:4px 10px 3px 7px; /* IE7 */
+}
+.buttons button img, .buttons a img{
+    margin:0 3px -3px 0 !important;
+    padding:0;
+    border:none;
+    width:16px;
+    height:16px;
+}
+
+
+/* STANDARD */
+
+button:hover, .buttons a:hover{
+    background-color:#dff4ff;
+    border:1px solid #c2e1ef;
+    color:#336699;
+}
+.buttons a:active{
+    background-color:#6299c5;
+    border:1px solid #6299c5;
+    color:#fff;
+}
+
+/* POSITIVE */
+
+button.positive, .buttons a.positive{
+    color:#529214;
+}
+.buttons a.positive:hover, button.positive:hover{
+    background-color:#E6EFC2;
+    border:1px solid #C6D880;
+    color:#529214;
+}
+.buttons a.positive:active{
+    background-color:#529214;
+    border:1px solid #529214;
+    color:#fff;
+}
+
+/* NEGATIVE */
+
+.buttons a.negative, button.negative{
+    color:#d12f19;
+}
+.buttons a.negative:hover, button.negative:hover{
+    background:#fbe3e4;
+    border:1px solid #fbc2c4;
+    color:#d12f19;
+}
+.buttons a.negative:active{
+    background-color:#d12f19;
+    border:1px solid #d12f19;
+    color:#fff;
+}
index a12c9a5c5a670a2d0520848a9ff36b45fbd38ec1..633ffee381ce48b37dbdfc4d328ebcef50bcc184 100644 (file)
@@ -14,7 +14,7 @@ ExternalFile=/tmp/test
 #YP Settings
 ServerStreamURL=http://www.pre-barreau.com
 ServerName=Pre-Barreau_-_ICP_-_AE_-_Adm_Correction
-ServerDescription=Pre-Barreau_-_ICP_-_AE_-_Adm_Correction_-_3_-_GIUSTINIANI_G._-_2e_cours
+ServerDescription=Pre-Barreau_-_ICP_-_AE_-_Adm_Correction_-_2_-_GIUSTINIANI_G._-_1er_cours
 ServerGenre=Teaching
 #Advanced Settings
 LogLevel=1
diff --git a/img/accept.png b/img/accept.png
new file mode 100644 (file)
index 0000000..89c8129
Binary files /dev/null and b/img/accept.png differ
diff --git a/img/bin.png b/img/bin.png
new file mode 100644 (file)
index 0000000..ebad933
Binary files /dev/null and b/img/bin.png differ
diff --git a/img/cancel.png b/img/cancel.png
new file mode 100644 (file)
index 0000000..c149c2b
Binary files /dev/null and b/img/cancel.png differ
diff --git a/img/control_pause_blue.png b/img/control_pause_blue.png
new file mode 100644 (file)
index 0000000..ec61099
Binary files /dev/null and b/img/control_pause_blue.png differ
diff --git a/img/control_play_blue.png b/img/control_play_blue.png
new file mode 100644 (file)
index 0000000..f8c8ec6
Binary files /dev/null and b/img/control_play_blue.png differ
diff --git a/img/control_stop.png b/img/control_stop.png
new file mode 100644 (file)
index 0000000..893bb60
Binary files /dev/null and b/img/control_stop.png differ
diff --git a/img/control_stop_blue.png b/img/control_stop_blue.png
new file mode 100644 (file)
index 0000000..e6f75d2
Binary files /dev/null and b/img/control_stop_blue.png differ
diff --git a/img/drive_add.png b/img/drive_add.png
new file mode 100644 (file)
index 0000000..29a35d5
Binary files /dev/null and b/img/drive_add.png differ
diff --git a/img/drive_burn.png b/img/drive_burn.png
new file mode 100644 (file)
index 0000000..80fd79f
Binary files /dev/null and b/img/drive_burn.png differ
diff --git a/img/drive_delete.png b/img/drive_delete.png
new file mode 100644 (file)
index 0000000..e6eb186
Binary files /dev/null and b/img/drive_delete.png differ
diff --git a/img/drive_error.png b/img/drive_error.png
new file mode 100644 (file)
index 0000000..309f639
Binary files /dev/null and b/img/drive_error.png differ
diff --git a/img/folder_go.png b/img/folder_go.png
new file mode 100644 (file)
index 0000000..34a736f
Binary files /dev/null and b/img/folder_go.png differ
diff --git a/img/folder_link.png b/img/folder_link.png
new file mode 100644 (file)
index 0000000..b9b75f6
Binary files /dev/null and b/img/folder_link.png differ
diff --git a/img/ipod_cast.png b/img/ipod_cast.png
new file mode 100644 (file)
index 0000000..6f6d340
Binary files /dev/null and b/img/ipod_cast.png differ
diff --git a/img/stop.png b/img/stop.png
new file mode 100644 (file)
index 0000000..0cfd585
Binary files /dev/null and b/img/stop.png differ
diff --git a/img/tick.png b/img/tick.png
new file mode 100644 (file)
index 0000000..a9925a0
Binary files /dev/null and b/img/tick.png differ
diff --git a/img/transmit.png b/img/transmit.png
new file mode 100644 (file)
index 0000000..f54bf73
Binary files /dev/null and b/img/transmit.png differ
diff --git a/img/transmit_add.png b/img/transmit_add.png
new file mode 100644 (file)
index 0000000..b7fd4e6
Binary files /dev/null and b/img/transmit_add.png differ
diff --git a/img/transmit_blue.png b/img/transmit_blue.png
new file mode 100644 (file)
index 0000000..7b1142f
Binary files /dev/null and b/img/transmit_blue.png differ
diff --git a/img/transmit_delete.png b/img/transmit_delete.png
new file mode 100644 (file)
index 0000000..3d72be2
Binary files /dev/null and b/img/transmit_delete.png differ
diff --git a/img/transmit_edit.png b/img/transmit_edit.png
new file mode 100644 (file)
index 0000000..eb9a3dd
Binary files /dev/null and b/img/transmit_edit.png differ
diff --git a/img/transmit_error.png b/img/transmit_error.png
new file mode 100644 (file)
index 0000000..fd1d449
Binary files /dev/null and b/img/transmit_error.png differ
diff --git a/img/transmit_go.png b/img/transmit_go.png
new file mode 100644 (file)
index 0000000..10137e5
Binary files /dev/null and b/img/transmit_go.png differ
diff --git a/img/tux.png b/img/tux.png
new file mode 100644 (file)
index 0000000..bbefe2e
Binary files /dev/null and b/img/tux.png differ
index eebb7e7579ec56a96aa1fde64d8b66492da98eec..0741eaece69cf3ce0e1cf5a30f2f0ed335a62546 100755 (executable)
@@ -34,6 +34,7 @@ import string
 import signal
 import unicodedata
 from tools import *
+from cgi import FieldStorage
 from tempfile import NamedTemporaryFile
 from mutagen.oggvorbis import OggVorbis
 from mutagen.id3 import ID3, TIT2, TP1, TAL, TDA, TCO, COM
@@ -103,7 +104,7 @@ class Station(Conference):
             os.makedirs(self.raw_dir)
 
     def set_oddcast_conf(self):
-        oddconf_temp = NamedTemporaryFile(suffix='.cfg')
+        #oddconf_temp = NamedTemporaryFile(suffix='.cfg')
         oddconf = open(self.odd_conf_file,'r')
         lines = oddconf.readlines()
         oddconf.close()
@@ -128,9 +129,10 @@ class Station(Conference):
             else:
                 newlines.append(line)
 
-        oddconf_temp_file = open(oddconf_temp.name,'w')
-        oddconf_temp_file.writelines(newlines)
-        self.odd_conf = oddconf_temp.name
+        oddconf = open(self.odd_conf_file,'w')
+        oddconf.writelines(newlines)
+        oddconf.close()
+        self.odd_conf = self.odd_conf_file
 
     def start_oddcast(self):
         command = 'oddcastv3 -n "'+clean_string(self.conference)[0:16]+'" -c '+self.odd_conf+ \
@@ -271,10 +273,11 @@ class Station(Conference):
         os.system('rsync -a '+self.media_dir+os.sep+' '+self.rsync_host+':'+os.sep+hostname+os.sep)
 
 
-class WebView:
+class WebView(FieldStorage):
     """Gives the web CGI frontend"""
     
     def __init__(self, school_file):
+        FieldStorage.__init__(self)
         self.conf = xml2dict(school_file)
         self.conf = self.conf['telecaster']
         self.interfaces = ['eth0', 'eth1', 'eth2']
@@ -417,12 +420,12 @@ class WebView:
         self.refresh = False
         self.header()
         self.hardware_data()
+        print "<form method=\"post\" action=\""+self.url+"/telecaster/telecaster.py\" name=\"formulaire\">"
         print "<div class=\"main\">"
         #print "<h5><span style=\"color: red\">"+message+"</span></h5>"
         #print "<h5><span style=\"color: red\">Attention, il est important de remplir tous les champs, y compris le commentaire !</span></h5>"
         print "<div \class=\"form\">"
-        print "<TABLE BORDER = 0>"
-        print "<FORM method=POST ACTION=\""+self.url+"/telecaster/telecaster.py\" name=\"formulaire\">"
+        print "<table border = 0>"
         print "<TR><TH align=\"left\">Titre :</TH><TD>"+self.title+"</TD></TR>"
         print "<TR><TH align=\"left\">D&eacute;partement :</TH>"
         print "<TD><select name=\"department\" onChange=\"choix(this.form)\">"
@@ -456,20 +459,22 @@ class WebView:
         for comment in self.comments:
             print "<option value=\""+comment['text']+"\">"+comment['text']+"</option>"
         print "</select></TD></TR>"
-       
-        print "</TABLE>"
+        print "</table>"
         print "</div>"
         
         #print "<h5><a href=\""+self.url+":"+self.port+"/augustins.pre-barreau.com_live."+self.format+".m3u\">Cliquez ici pour &eacute;couter le flux continu 24/24 en direct</a></h5>"
-        print '<hr>'
-        print "<h5><a href=\""+self.url+"/media/\">Cliquez ici pour acc&eacute;der aux archives</a></h5>"
-        print "<h5><a href=\""+self.url+"/backup/\">Cliquez ici pour acc&eacute;der aux archives de secours</a></h5>"
+        
         print "</div>"
         print "<div class=\"tools\">"
-        print "<INPUT TYPE = hidden NAME = \"action\" VALUE = \"start\">"
-        print "<INPUT TYPE = submit VALUE = \"Enregistrer\">"
-        print "</FORM>"
+        print "<div class=\"buttons\">"
+        #print "<INPUT TYPE = hidden NAME = \"action\" VALUE = \"start\">"
+        print "<button type=\"submit\" name=\"action\" value=\"start\" class=\"negative\"><img src=\"img/stop.png\" alt=\"\"/>Enregistrer</button>"
+        print "<a href=\""+self.url+"/media/\"><img src=\"img/folder_go.png\" alt=\"\"/>Archives</a>"
+        print "<a href=\""+self.url+"/backup/\"><img src=\"img/bin.png\" alt=\"\"/>Corbeille</a>"
+        #print "<INPUT TYPE = submit VALUE = \"Enregistrer\">"
         print "</div>"
+        print "</div>"
+        print "</form>"
         self.colophon()
         self.footer()
 
@@ -493,35 +498,35 @@ class WebView:
         self.header()
         self.hardware_data()
         print "<div class=\"main\">"
-        
-        print "<hr>"
-        if writing:
-            print "<h4><span style=\"color: green\">Enregistrement en cours...</span></h4>"
-        else:
-            print "<h4><span style=\"color: red\">PAS d'enregistrement en cours !</span></h4>"
-        print '<hr>'
-        if casting:
-            print "<h4><span style=\"color: green\">Diffusion en cours...</span></h4>"
-        else:
-            print "<h4><span style=\"color: red\">PAS de diffusion en cours !</span></h4>"
-        print "<hr>"
-        print "<TABLE BORDER = 0>"
+        print "<table border = 0>"
         print "<TR><TH align=\"left\">Titre :</TH><TD>"+self.title+"</TD></TR>"
         print "<TR><TH align=\"left\">D&eacute;partement :</TH><TD>"+department+"</TD><TR>"
         print "<TR><TH align=\"left\">Conference :</TH><TD>"+conference+"</TD><TR>"
         print "<TR><TH align=\"left\">Session :</TH><TD>"+session+"</TD><TR>"
         print "<TR><TH align=\"left\">Professeur :</TH><TD>"+professor+"</TD><TR>"
         print "<TR><TH align=\"left\">Commentaire :</TH><TD>"+comment+"</TD><TR>"
-        print "</TABLE>"
-        print "<hr>"
-        print "<h5><a href=\""+self.url+":"+self.port+"/"+clean_string(self.title)+"_-_"+clean_string(department)+"_-_"+clean_string(conference)+"."+self.format+".m3u\">Cliquez ici pour &eacute;couter cette formation en direct</a></h5>"
+        print "</table>"
+        #print "<h5><a href=\""+self.url+":"+self.port+"/"+clean_string(self.title)+"_-_"+clean_string(department)+"_-_"+clean_string(conference)+"."+self.format+".m3u\">Cliquez ici pour &eacute;couter cette formation en direct</a></h5>"
         print "</div>"
+        print "<form method=\"post\" action=\""+self.url+"/telecaster/telecaster.py\">"
         print "<div class=\"tools\">"
-        print "<FORM METHOD = post ACTION = \""+self.url+"/telecaster/telecaster.py\">"
-        print "<INPUT TYPE = hidden NAME = \"action\" VALUE = \"stop\">"
-        print "<INPUT TYPE = submit VALUE = \"STOP\">"
-        print "</FORM>"
+        print "<div class=\"buttons\">"
+        if writing:
+            print "<button type=\"submit\" class=\"positive\"><img src=\"img/drive_add.png\" alt=\"\"/>Recording...</button"
+        else:
+            print "<button type=\"submit\" class=\"negative\"><img src=\"img/drive_error.png\" alt=\"\"/>NOT Recording !</button"
+        if casting:
+            print "<button type=\"submit\" class=\"positive\"><img src=\"img/transmit_add.png\" alt=\"\"/>Diffusing...</button"
+        else:
+            print "<button type=\"submit\" class=\"negative\"><img src=\"img/transmit_error.png\" alt=\"\"/>NOT Diffusing !</button"
+        print "<a href=\""+self.url+":"+self.port+"/"+clean_string(self.title)+"_-_"+clean_string(department)+"_-_"+clean_string(conference)+"."+self.format+".m3u\"><img src=\"img/control_play_blue.png\" alt=\"\"/>Play</a>"
+        print "<button type=\"submit\" name=\"action\" value=\"stop\" class=\"negative\"><img src=\"img/cancel.png\" alt=\"\"/>Stop</button>"
+        
+        #print "<INPUT TYPE = hidden NAME = \"action\" VALUE = \"stop\">"
+        #print "<INPUT TYPE = submit VALUE = \"STOP\">"
         print "</div>"
+        print "</div>"
+        print "</form>"
         self.colophon()
         self.footer()
 
@@ -546,14 +551,10 @@ class TeleCaster:
         odd_pid = get_pid('^oddcastv3 -n [^LIVE]', self.uid)
         rip_pid = get_pid('streamripper ', self.uid)
         writing = False
-        casting = True
-        if rip_pid != []:
-            writing = True
-        if odd_pid == []:
-            casting = False
-        
-        w = WebView(self.school_file)
-        form = cgi.FieldStorage()
+        casting = False
+        writing = rip_pid != []
+        casting = odd_pid != []        
+        form = WebView(self.school_file)
         
         if odd_pid == [] and form.has_key("action") and \
             form.has_key("department") and form.has_key("conference") and \
@@ -561,37 +562,32 @@ class TeleCaster:
             form["action"].value == "start":
             
             self.conference_dict = {'title': self.title,
-                        'department': form["department"].value,
-                        'conference': form["conference"].value,
-                        'session': form["session"].value,
-                        'professor': form["professor"].value,
-                        'comment': form["comment"].value}
+                        'department': form.getfirst("department"),
+                        'conference': form.getfirst("conference"),
+                        'session': form.getfirst("session"),
+                        'professor': form.getfirst("professor"),
+                        'comment': form.getfirst("comment")}
             
             s = Station(self.conf_file, self.conference_dict, self.lock_file)
             s.start()
-            if get_pid('^oddcastv3 -n [^LIVE]', self.uid) != []:
-                casting = True
-            if get_pid('streamripper ', self.uid) == []:
-                writing = False
-            w.stop_form(self.conference_dict, writing, casting)
+            time.sleep(1)
+            #w.stop_form(self.conference_dict, writing, casting)
+            self.main()
             
         elif odd_pid != [] and os.path.exists(self.lock_file) and not form.has_key("action"):
             self.conference_dict = get_conference_from_lock(self.lock_file)
-            if get_pid('^oddcastv3 -n [^LIVE]', self.uid) != []:
-               casting = True
-            if get_pid('streamripper ', self.uid) == []:
-                writing = False
-            w.stop_form(self.conference_dict, writing, casting)
+            form.stop_form(self.conference_dict, writing, casting)
 
         elif odd_pid != [] and form.has_key("action") and form["action"].value == "stop":
             if os.path.exists(self.lock_file):
                 self.conference_dict = get_conference_from_lock(self.lock_file)
             s = Station(self.conf_file, self.conference_dict, self.lock_file)
             s.stop()
-            w.start_form()
+            time.sleep(1)
+            self.main()
 
         elif odd_pid == []:
-            w.start_form()
+            form.start_form()
 
 
 # Call main function.