border: 1px solid #FFFFFF;
padding:0.5em;
margin: 0;
+ height: 32px;
}
div.colophon { 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;
+}
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
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()
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+ \
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']
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épartement :</TH>"
print "<TD><select name=\"department\" onChange=\"choix(this.form)\">"
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 écouter le flux continu 24/24 en direct</a></h5>"
- print '<hr>'
- print "<h5><a href=\""+self.url+"/media/\">Cliquez ici pour accéder aux archives</a></h5>"
- print "<h5><a href=\""+self.url+"/backup/\">Cliquez ici pour accé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()
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é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 é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 é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()
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 \
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.