From be4b37b2e2416e5831b36e5721b146dba7d4ff20 Mon Sep 17 00:00:00 2001 From: yomguy <> Date: Mon, 26 Nov 2007 17:51:06 +0000 Subject: [PATCH] Bug Fixes --- pre-barreau.xml | 195 ++++++++++++++++++------------------------------ teleoddcast.cfg | 8 +- teleoddcast.py | 125 +++++++++++++++---------------- teleoddcast.xml | 4 +- tools.py | 9 +++ 5 files changed, 145 insertions(+), 196 deletions(-) diff --git a/pre-barreau.xml b/pre-barreau.xml index e48b49f..20940f6 100644 --- a/pre-barreau.xml +++ b/pre-barreau.xml @@ -1,256 +1,203 @@ http://augustins.pre-barreau.com - + Augustins - Pre-Barreau + CRFPA - Liberté publiques - Cours - + Liberté publiques - Cours - Note de synthèse - Corrections - + Note de synthèse - Corrections - Droit civil - Cours - + Droit civil - Cours - Droit civil - Corrections - + Droit civil - Corrections - Procédure administrative et contentieuse - Cours - + Procédure administrative et contentieuse - Cours - Procédure administrative et contentieuse - Corrections - + Procédure administrative et contentieuse - Corrections - Procédure civile - Cours - + Procédure civile - Cours - Procédure civile - Corrections - + Procédure civile - Corrections - Procédure pénale - Cours - + Procédure pénale - Cours - Procédure pénale - Corrections - + Procédure pénale - Corrections - Droit commercial des affaires - Cours - + Droit commercial des affaires - Cours - Droit commercial des affaires - Corrections - + Droit commercial des affaires - Corrections - Droit communautaire et européen - Cours - + Droit communautaire et européen - Cours - Droit communautaire et européen - Corrections - + Droit communautaire et européen - Corrections - Droit fiscal - Cours - + Droit fiscal - Cours - Droit fiscal - Corrections - + Droit fiscal - Corrections - Droit pénal - Cours - + Droit pénal - Cours - Droit pénal - Corrections - + Droit pénal - Corrections - Droit de la famille et des personnes - Cours - + Droit de la famille et des personnes - Cours - Droit de la famille et des personnes - Corrections - + Droit de la famille et des personnes - Corrections - Droit patrimonial - Cours - + Droit patrimonial - Cours - Droit patrimonial - Corrections - + Droit patrimonial - Corrections - Droit du travail - Cours - + Droit du travail - Cours - Droit du travail - Corrections - + Droit du travail - Corrections - Droit administratif - Cours - + Droit administratif - Cours - Droit administratif - Corrections - + Droit administratif - Corrections - Droit public des activités économiques - Cours - + Droit public des activités économiques - Cours - Droit public des activités économiques - Corrections - + Droit public des activités économiques - Corrections - Droit international privé - Cours - + Droit international privé - Cours - Droit international privé - Corrections - + Droit international privé - Corrections - Procédures collectives et sûretés - Cours - + Procédures collectives et sûretés - Cours - Procédures collectives et sûretés - Corrections - + Procédures collectives et sûretés - Corrections - Procédure communautaire - Cours - + Procédure communautaire - Cours - Procédures civile d'exécution - Cours - + Procédures civile d'exécution - Cours - Comptabilité privée - Cours - + Comptabilité privée - Cours - Finances publiques - Cours - + Finances publiques - Cours - REUNION - + REUNION - TEST - + TEST - + - + AE - - + Administratif_Cours - Administratif_Cours - + Adm_Correction - Adm_Correction - + Civil_Correction - Civil_Correction - + Commercial_Correctio - Commercial_Correctio - + Commercial_Cours - Commercial_Cours - + Deontologie_Cours - Deontologie_Cours - + Droit civil - Cours - Droit civil - Cours - + Methodo_Oraux - Methodo_Oraux - + Penal_Correction - Penal_Correction - + Penal_Cours - Penal_Cours - + Procedures_Cours - Procedures_Cours - + Reunion_info - Reunion_info - + Social_Corrections - Social_Corrections - + Social_Cours - Social_Cours - + REUNION - REUNION - - - - TEST - + TEST - + - + ENM - TEST - + TEST + + + REUNION - + - + FJP - TEST - + TEST + + + REUNION - + diff --git a/teleoddcast.cfg b/teleoddcast.cfg index d8c19db..539d6b5 100644 --- a/teleoddcast.cfg +++ b/teleoddcast.cfg @@ -1,7 +1,7 @@ Server=localhost Port=8000 -ServerPassword=streampreb -ServerMountpoint=/Pre-barreau_-_Augustins_-_CRFPA_-_Droit_civil_-_Corrections.ogg +ServerPassword=source2parisson +ServerMountpoint=/My_best_funky_station_-_AE_-_Civil_Correction.ogg ServerPublic=0 AutomaticReconnectSecs=10 Encode=OggVorbis @@ -13,8 +13,8 @@ ServerType=Icecast2 ExternalFile=/home/pre-barreau/augustins/audio/ #YP Settings ServerStreamURL=http://www.pre-barreau.com -ServerName=Pre-barreau_-_Augustins_-_CRFPA_-_Droit_civil_-_Corrections_-_1 -ServerDescription=Pre-barreau_-_Augustins_-_CRFPA_-_Droit_civil_-_Corrections_-_1_-_edfez_-_ezf +ServerName=My_best_funky_station_-_AE_-_Civil_Correction_-_1 +ServerDescription=My_best_funky_station_-_AE_-_Civil_Correction_-_1_-_sf_-_ze ServerGenre=Teaching #Advanced Settings LogLevel=1 diff --git a/teleoddcast.py b/teleoddcast.py index 388983d..6463568 100755 --- a/teleoddcast.py +++ b/teleoddcast.py @@ -36,11 +36,11 @@ class Course: """A course in a class room""" def __init__(self, dict): - self.department = course_dict['department'] - self.course = course_dict['course'] - self.session = course_dict['session'] - self.professor = course_dict['professor'] - self.comment = course_dict['comment'] + self.department = dict['department'] + self.course = dict['course'] + self.session = dict['session'] + self.professor = dict['professor'] + self.comment = dict['comment'] def get_info(self): return self.title, self.department, self.course, self.session, self.professor, self.comment @@ -61,25 +61,19 @@ class TeleOddCast(Course): self.port = self.conf['server']['port'] self.password = self.conf['server']['sourcepassword'] self.url = 'http://'+self.host+':'+self.port - self.uid = os.getuid() - self.odd_pid = get_pid('^oddcastv3 -n [^LIVE]', self.uid) - self.rip_pid = get_pid('streamripper ' + self.url + self.mount_point, self.uid) self.odd_conf_file = self.conf['server']['odd_conf_file'] - self.ServerDescription = clean_string('_-_'.join(self.title, - self.department, - self.course, - self.session, - self.professor, - self.comment)) - self.ServerName = clean_string('_-_'.join(self.title, - self.department, - self.course, - self.session)) + self.description = [self.title, self.department, self.course, self.session, self.professor, self.comment] + self.server_name = [self.title, self.department, self.course, self.session] + self.ServerDescription = clean_string('_-_'.join(self.description)) + self.ServerName = clean_string('_-_'.join(self.server_name)) self.mount_point = '/' + clean_string(self.title) + '_-_' + \ clean_string(self.department) + '_-_' + \ clean_string(self.course)+'.ogg' self.lock_file = self.root_dir + self.ServerDescription + '.lock' self.filename = self.ServerDescription + '.ogg' + self.uid = os.getuid() + self.odd_pid = get_pid('^oddcastv3 -n [^LIVE]', self.uid) + self.rip_pid = get_pid('streamripper ' + self.url + self.mount_point, self.uid) def set_oddcast_conf(self): @@ -114,16 +108,10 @@ class TeleOddCast(Course): os.system(command) self.set_lock() time.sleep(1) - return mount_point def set_lock(self): lock = open(self.lock_file,'w') - lock_text = clean_string('_*_'.join(self.title, - self.department, - self.course, - self.session, - self.professor, - self.comment)) + lock_text = clean_string('_*_'.join(self.description)) lock_text = lock_text.replace('\n','') lock.write(lock_text) lock.close() @@ -149,7 +137,7 @@ class TeleOddCast(Course): time.sleep(1) date = datetime.datetime.now().strftime("%Y") dirname = self.media_dir + os.sep + self.department + os.sep + \ - clean_string('_-_'.join(self.title, self.department, self.course, self.session)) + clean_string('_-_'.join(self.server_name)) if os.path.exists(dirname) and os.path.exists(dirname+os.sep+'incomplete'): shutil.move(dirname+os.sep+'incomplete'+os.sep+' - .ogg',dirname+os.sep) @@ -158,7 +146,7 @@ class TeleOddCast(Course): def write_tags(self): date = datetime.datetime.now().strftime("%Y") - new_title = clean_string('_-_'.join(self.title, self.department, self.course, self.session) + new_title = clean_string('_-_'.join(self.server_name)) dirname = self.media_dir + os.sep + self.department + os.sep + new_title if os.path.exists(dirname+os.sep+self.filename): audio = OggVorbis(dirname+os.sep+self.filename) @@ -191,8 +179,11 @@ class WebView: self.conf = xml2dict(school_file) self.conf = self.conf['teleoddcast'] self.url = self.conf['url'] - self.departments = self.conf['department']['name'] - self.len_departments = str(len(self.departments)) + self.title = self.conf['title'] + self.departments = self.conf['department'] + #print self.departments + #self.courses = self.conf['department']['courses'] + self.len_departments = len(self.departments) def header(self): # Required header that tells the browser how to render the HTML. @@ -205,24 +196,29 @@ class WebView: print 'function choix(formulaire)' print '{var j; var i = formulaire.department.selectedIndex;' print 'if (i == 0)' - print 'for(j = 1; j < '+ self.len_departments + '; j++)' + print 'for(j = 1; j < '+ str(self.len_departments) + '; j++)' print 'formulaire.course.options[j].text="";' - print 'formulaire.course.options[j].value="";' + #print 'formulaire.course.options[j].value="";' print 'else{' print ' switch (i){' - for k in range(1,self.len_departments) + for k in range(0,self.len_departments): department = self.departments[k] - courses = dict2tuple(department['courses']) - print ' case '+k+' : var text = new Array('+courses+'); ' + courses = department['courses'] + #print courses + courses_t = dict2tuple(courses) + #print courses + courses = '"'+'","'.join(courses_t)+'"' + print ' case '+str(k+1)+' : var text = new Array('+courses+'); ' print ' break;' print ' }' - print ' for(j = 0; j<'+self.len_departments+'; j++)' - print ' formulaire.course.options[j+1].text=text[j];}' - print ' formulaire.course.options[j+1].value=text[j];}' + print ' for(j = 0; j<50; j++)' + print ' formulaire.course.options[j+1].text=text[j];' + #print ' formulaire.course.options[j+1].value=text[j];' + print '}' print ' formulaire.course.selectedIndex=0;}' print '' - print "" + print "" print "
" print "
" @@ -231,7 +227,7 @@ class WebView: def colophon(self): print "
" - print "TeleOddCast "+self.version+" © 2007 Parisson. Tous droits réservés." + print "TeleOddCast "+version+" © 2007 Parisson. Tous droits réservés." print "
" def footer(self): @@ -244,19 +240,20 @@ class WebView: print "
" print "
Cliquez ici pour écouter le flux continu 24/24 en direct
" print "\t" - print "\t\t" + print "\t\t" print "\t\t" print "\t\t" print "" print "\t\t" print "" @@ -283,7 +280,6 @@ class WebView: def stop_form(self, course_dict): """Stop page""" - title = course_dict['title'] department = course_dict['department'] course = course_dict['course'] session = course_dict['session'] @@ -296,7 +292,7 @@ class WebView: print "
" print "\t
Titre :"+self.title+"
Département :
Intitulé du cours :
" print "\t\t" - print "\t\t" + print "\t\t" print "\t\t" print "\t\t" print "\t\t" @@ -304,34 +300,33 @@ class WebView: print "\t\t" print "\t
Titre :"+title+"
Titre :"+self.title+"
Département :"+department+"
Intitulé du cours :"+course+"
Session :"+session+"
Commentaire :"+comment+"
" print "
" - print "
Cliquez ici pour écouter cette formation en direct
" + print "
Cliquez ici pour écouter cette formation en direct
" print "
" print "
" print "\t" print "\t" print "\t" print "
" - colophon() - footer() + self.colophon() + self.footer() def main(): - """Main function""" - + """Main function""" conf_file = 'teleoddcast.xml' - school_file = 'pre-barreau.xml' - odd_conf_file = 'teleoddcast.cfg' + school_file = 'pre-barreau.xml' + odd_conf_file = 'teleoddcast.cfg' lock_file = 'teleoddcast.lock' - uid = os.getuid() + uid = os.getuid() odd_pid = get_pid('^oddcastv3 -n [^LIVE]', uid) w = WebView(school_file) - form = cgi.FieldStorage() + form = cgi.FieldStorage() - if odd_pid == [] and form.has_key("action") and \ - form.has_key("department") and form.has_key("course") and form.has_key("professor") \ - and form.has_key("comment") and form["action"].value == "start": + if odd_pid == [] and form.has_key("action") and \ + form.has_key("department") and form.has_key("course") and form.has_key("professor") \ + and form.has_key("comment") and form["action"].value == "start": - course_dict = {'department': form["department"].value, + course_dict = {'department': form["department"].value, 'course': form["course"].value, 'session': form["session"].value, 'professor': form["professor"].value, @@ -341,20 +336,20 @@ def main(): t.start() w.stop_form(course_dict) - elif odd_pid != [] and os.path.exists(lock_file) and not form.has_key("action"): + elif odd_pid != [] and os.path.exists(lock_file) and not form.has_key("action"): t = TeleOddCast(conf_file, course_dict) title,department,course,session,professor,comment = t.get_info() - w.stop_form(course_dict) + w.stop_form(course_dict) - elif oddcast_pid != [] and form.has_key("action") and form["action"].value == "stop": + elif odd_pid != [] and form.has_key("action") and form["action"].value == "stop": t = TeleOddCast(conf_file, course_dict) - if os.path.exists(lock_file): + if os.path.exists(lock_file): title,department,course,session,professor,comment = t.get_info() t.stop() - w.start_form() + w.start_form() - elif oddcast_pid == []: - w.start_form() + elif odd_pid == []: + w.start_form() # Call main function. if __name__ == '__main__': diff --git a/teleoddcast.xml b/teleoddcast.xml index ec98dc1..4cd2dbd 100644 --- a/teleoddcast.xml +++ b/teleoddcast.xml @@ -1,6 +1,5 @@ - - + My_Station_5 My best funky station My personal best funky playlist ever ! @@ -25,5 +24,4 @@ 2 1 - diff --git a/tools.py b/tools.py index 425cd6a..fc80489 100644 --- a/tools.py +++ b/tools.py @@ -66,4 +66,13 @@ def get_params_from_lock(lock_file): lockfile.close() return params_ok +def dict2tuple(dict): + len_dict = len(dict['course']) + if len_dict == 1: + return dict['course']['name'] + else: + tup = [] + for value in dict['course']: + tup.append(value['name']) + return tup -- 2.39.5