From 93f9acf3bf59d0265c3be5dbb73a504eb2598355 Mon Sep 17 00:00:00 2001 From: yomguy Date: Sun, 8 Jun 2008 20:53:15 +0000 Subject: [PATCH] * Rename courses to conferences --- README | 3 +- etc/default_conferences.xml | 49 +++++++ etc/default_courses.xml | 64 ++++----- etc/pre-barreau_conferences.xml | 205 ++++++++++++++++++++++++++ etc/pre-barreau_courses.xml | 248 ++++++++++++++++---------------- etc/teleoddcast.cfg | 6 +- teleoddcast.py | 106 +++++++------- tools.py | 32 ++--- 8 files changed, 483 insertions(+), 230 deletions(-) create mode 100644 etc/default_conferences.xml create mode 100644 etc/pre-barreau_conferences.xml diff --git a/README b/README index 64b0736..5aee168 100644 --- a/README +++ b/README @@ -2,4 +2,5 @@ teleoddcast by yomguy # DEPENDS -icecast2, jackd, oddcastv3-jack, streamrippper, pgrep +icecast2, jackd, oddcastv3-jack, streamrippper, pgrep, vorbis-tools, lame + diff --git a/etc/default_conferences.xml b/etc/default_conferences.xml new file mode 100644 index 0000000..c450d20 --- /dev/null +++ b/etc/default_conferences.xml @@ -0,0 +1,49 @@ + + http://localhost + School Example + 8000 + + Audio + + + Conference 1 + + + Conference 2 + + + + + Computer + + + Conference 1 + + + Conference 2 + + + + + Physics + + + Conference 1 + + + Conference 2 + + + + + Sociology + + + Conference 1 + + + Conference 1 + + + + diff --git a/etc/default_courses.xml b/etc/default_courses.xml index 22a72ab..c450d20 100644 --- a/etc/default_courses.xml +++ b/etc/default_courses.xml @@ -4,46 +4,46 @@ 8000 Audio - - - Course 1 - - - Course 2 - - + + + Conference 1 + + + Conference 2 + + Computer - - - Course 1 - - - Course 2 - - + + + Conference 1 + + + Conference 2 + + Physics - - - Course 1 - - - Course 2 - - + + + Conference 1 + + + Conference 2 + + Sociology - - - Course 1 - - - Course 1 - - + + + Conference 1 + + + Conference 1 + + diff --git a/etc/pre-barreau_conferences.xml b/etc/pre-barreau_conferences.xml new file mode 100644 index 0000000..f0b17ac --- /dev/null +++ b/etc/pre-barreau_conferences.xml @@ -0,0 +1,205 @@ + + http://augustins.pre-barreau.com + Augustins - Pré-Barreau + 8000 + + + CRFPA + + + Liberté publiques - Cours + + + Note de synthèse - Corrections + + + Droit civil - Cours + + + Droit civil - Corrections + + + Procédure administrative et contentieuse - Cours + + + Procédure administrative et contentieuse - Corrections + + + Procédure civile - Cours + + + Procédure civile - Corrections + + + Procédure pénale - Cours + + + Procédure pénale - Corrections + + + Droit commercial des affaires - Cours + + + Droit commercial des affaires - Corrections + + + Droit communautaire et européen - Cours + + + Droit communautaire et européen - Corrections + + + Droit fiscal - Cours + + + Droit fiscal - Corrections + + + Droit pénal - Cours + + + Droit pénal - Corrections + + + Droit de la famille et des personnes - Cours + + + Droit de la famille et des personnes - Corrections + + + Droit patrimonial - Cours + + + Droit patrimonial - Corrections + + + Droit du travail - Cours + + + Droit du travail - Corrections + + + Droit administratif - Cours + + + Droit administratif - Corrections + + + Droit public des activités économiques - Cours + + + Droit public des activités économiques - Corrections + + + Droit international privé - Cours + + + Droit international privé - Corrections + + + Procédures collectives et sûretés - Cours + + + Procédures collectives et sûretés - Corrections + + + Procédure communautaire - Cours + + + Procédures civile d'exécution - Cours + + + Comptabilité privée - Cours + + + Finances publiques - Cours + + + REUNION + + + TEST + + + + + + AE + + + Administratif_Cours + + + Adm_Correction + + + Civil_Correction + + + Commercial_Correctio + + + Commercial_Cours + + + Deontologie_Cours + + + Droit civil - Cours + + + Methodo_Oraux + + + Penal_Correction + + + Penal_Cours + + + Procedures_Cours + + + Reunion_info + + + Social_Corrections + + + Social_Cours + + + REUNION + + + TEST + + + + + + ENM + + + TEST + + + REUNION + + + + + + + FJP + + + TEST + + + REUNION + + + + + diff --git a/etc/pre-barreau_courses.xml b/etc/pre-barreau_courses.xml index 98326e4..f0b17ac 100644 --- a/etc/pre-barreau_courses.xml +++ b/etc/pre-barreau_courses.xml @@ -5,201 +5,201 @@ CRFPA - - + + Liberté publiques - Cours - - + + Note de synthèse - Corrections - - + + Droit civil - Cours - - + + Droit civil - Corrections - - + + Procédure administrative et contentieuse - Cours - - + + Procédure administrative et contentieuse - Corrections - - + + Procédure civile - Cours - - + + Procédure civile - Corrections - - + + Procédure pénale - Cours - - + + Procédure pénale - Corrections - - + + Droit commercial des affaires - Cours - - + + Droit commercial des affaires - Corrections - - + + Droit communautaire et européen - Cours - - + + Droit communautaire et européen - Corrections - - + + Droit fiscal - Cours - - + + Droit fiscal - Corrections - - + + Droit pénal - Cours - - + + Droit pénal - Corrections - - + + Droit de la famille et des personnes - Cours - - + + Droit de la famille et des personnes - Corrections - - + + Droit patrimonial - Cours - - + + Droit patrimonial - Corrections - - + + Droit du travail - Cours - - + + Droit du travail - Corrections - - + + Droit administratif - Cours - - + + Droit administratif - Corrections - - + + Droit public des activités économiques - Cours - - + + Droit public des activités économiques - Corrections - - + + Droit international privé - Cours - - + + Droit international privé - Corrections - - + + Procédures collectives et sûretés - Cours - - + + Procédures collectives et sûretés - Corrections - - + + Procédure communautaire - Cours - - + + Procédures civile d'exécution - Cours - - + + Comptabilité privée - Cours - - + + Finances publiques - Cours - - + + REUNION - - + + TEST - - + + AE - - + + Administratif_Cours - - + + Adm_Correction - - + + Civil_Correction - - + + Commercial_Correctio - - + + Commercial_Cours - - + + Deontologie_Cours - - + + Droit civil - Cours - - + + Methodo_Oraux - - + + Penal_Correction - - + + Penal_Cours - - + + Procedures_Cours - - + + Reunion_info - - + + Social_Corrections - - + + Social_Cours - - + + REUNION - - + + TEST - - + + ENM - - + + TEST - - + + REUNION - - + + FJP - - + + TEST - - + + REUNION - - + + diff --git a/etc/teleoddcast.cfg b/etc/teleoddcast.cfg index a4d9b40..e5695ab 100644 --- a/etc/teleoddcast.cfg +++ b/etc/teleoddcast.cfg @@ -1,7 +1,7 @@ Server=localhost Port=8000 ServerPassword=source2parisson -ServerMountpoint=/My_station_-_CRFPA_-_Procedure_penale_-_Cours.ogg +ServerMountpoint=/Default_School_-_Computer_-_Conference_1.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=My_station_-_CRFPA_-_Procedure_penale_-_Cours_-_1 -ServerDescription=My_station_-_CRFPA_-_Procedure_penale_-_Cours_-_1_-_GP_-_GP +ServerName=Default_School_-_Computer_-_Conference_1 +ServerDescription=Default_School_-_Computer_-_Conference_1_-_1_-_azefdoj_-_azef ServerGenre=Teaching #Advanced Settings LogLevel=1 diff --git a/teleoddcast.py b/teleoddcast.py index 686cb43..230cb8d 100755 --- a/teleoddcast.py +++ b/teleoddcast.py @@ -20,8 +20,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. """ -version = '0.3.1' - +version = '0.3.2' import os import cgi @@ -34,27 +33,27 @@ from tools import * from mutagen.oggvorbis import OggVorbis -class Course: - """A course in a class room""" +class Conference: + """A conference object including metadata""" def __init__(self, dict): self.title = dict['title'] self.department = dict['department'] - self.course = dict['course'] + self.conference = dict['conference'] 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 + return self.title, self.department, self.conference, self.session, self.professor, self.comment -class Station(Course): +class Station(Conference): """Control the Oddcastv3-jack thread which send audio data to the icecast server and the Streamripper thread which write audio on the hard disk""" - def __init__(self, conf_file, course_dict, lock_file): - Course.__init__(self, course_dict) + def __init__(self, conf_file, conference_dict, lock_file): + Conference.__init__(self, conference_dict) self.date = datetime.datetime.now().strftime("%Y") self.conf = xml2dict(conf_file) self.conf = self.conf['teleoddcast'] @@ -65,13 +64,13 @@ class Station(Course): self.password = self.conf['server']['sourcepassword'] self.url = 'http://'+self.host+':'+self.port self.odd_conf_file = self.conf['server']['odd_conf_file'] - self.description = [self.title, self.department, self.course, self.session, self.professor, self.comment] - self.server_name = [self.title, self.department, self.course] + self.description = [self.title, self.department, self.conference, self.session, self.professor, self.comment] + self.server_name = [self.title, self.department, self.conference] 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' + clean_string(self.conference)+'.ogg' self.lock_file = self.root_dir + os.sep + self.conf['server']['lock_file'] self.filename = self.ServerDescription + '.ogg' self.output_dir = self.media_dir + os.sep + self.department + os.sep + self.date @@ -111,7 +110,7 @@ class Station(Course): oddconf.close() def start_oddcast(self): - command = 'oddcastv3 -n "'+clean_string(self.course)[0:16]+'" -c '+self.odd_conf_file+ \ + command = 'oddcastv3 -n "'+clean_string(self.conference)[0:16]+'" -c '+self.odd_conf_file+ \ ' alsa_pcm:capture_1 alsa_pcm:capture_2 > /dev/null &' os.system(command) self.set_lock() @@ -180,8 +179,7 @@ class Station(Course): self.del_lock() self.mp3_convert() - def start_mp3cast(self): - + def start_mp3cast(self): item_id = item_id source = source metadata = metadata @@ -199,8 +197,7 @@ class Station(Course): yield chunk def core_process(self, command, buffer_size, dest): - """Encode and stream audio data through a generator""" - + """Encode and stream audio data through a generator""" __chunk = 0 file_out = open(dest,'w') try: @@ -226,7 +223,8 @@ class Station(Course): file_out.close() class WebView: - + """Gives the web CGI frontend""" + def __init__(self, school_file): self.conf = xml2dict(school_file) self.conf = self.conf['teleoddcast'] @@ -235,9 +233,9 @@ class WebView: self.title = self.conf['title'] self.departments = self.conf['department'] #print self.departments - #self.courses = self.conf['department']['courses'] + #self.conferences = self.conf['department']['conferences'] self.len_departments = len(self.departments) - self.course_nb_max = 40 + self.conference_nb_max = 40 def header(self): # Required header that tells the browser how to render the HTML. @@ -251,25 +249,25 @@ class WebView: print '{var j; var i = formulaire.department.selectedIndex;' print 'if (i == 0)' print 'for(j = 1; j < '+ str(self.len_departments) + '; j++)' - print 'formulaire.course.options[j].text="";' - #print 'formulaire.course.options[j].value="";' + print 'formulaire.conference.options[j].text="";' + #print 'formulaire.conference.options[j].value="";' print 'else{' print ' switch (i){' for k in range(0, self.len_departments): department = self.departments[k] - 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+'); ' + conferences = department['conferences'] + #print conferences + conferences_t = dict2tuple(conferences) + #print conferences + conferences = '"'+'","'.join(conferences_t)+'"' + print ' case '+str(k+1)+' : var text = new Array('+conferences+'); ' print ' break;' print ' }' - print ' for(j = 0; j<'+str(self.course_nb_max)+'; j++)' - print ' formulaire.course.options[j+1].text=text[j];' - #print ' formulaire.course.options[j+1].value=text[j];' + print ' for(j = 0; j<'+str(self.conference_nb_max)+'; j++)' + print ' formulaire.conference.options[j+1].text=text[j];' + #print ' formulaire.conference.options[j+1].value=text[j];' print '}' - print ' formulaire.course.selectedIndex=0;}' + print ' formulaire.conference.selectedIndex=0;}' print '' print "" @@ -280,8 +278,9 @@ class WebView: print "" def colophon(self): + date = datetime.datetime.now().strftime("%Y") print "
" - print "TeleOddCast "+version+" © 2007 Parisson. Tous droits réservés." + print "TeleOddCast "+version+" © "+date+" Parisson. Tous droits réservés." print "
" def footer(self): @@ -305,9 +304,9 @@ class WebView: print "" print "\t\tIntitulé du cours :" - print "" print "" - for i in range(1,self.course_nb_max): + for i in range(1,self.conference_nb_max): print "" print "" @@ -332,13 +331,13 @@ class WebView: self.footer() - def stop_form(self, course_dict): + def stop_form(self, conference_dict): """Stop page""" - department = course_dict['department'] - course = course_dict['course'] - session = course_dict['session'] - professor = course_dict['professor'] - comment = course_dict['comment'] + department = conference_dict['department'] + conference = conference_dict['conference'] + session = conference_dict['session'] + professor = conference_dict['professor'] + comment = conference_dict['comment'] self.header() print "
" @@ -348,14 +347,14 @@ class WebView: print "\t\t
" print "\t\tTitre :"+self.title+"" print "\t\tDépartement :"+department+"" - print "\t\tIntitulé du cours :"+course+"" + print "\t\tIntitulé du cours :"+conference+"" print "\t\tSession :"+session+"" print "\t\tProfesseur :"+professor+"" print "\t\tCommentaire :"+comment+"" print "\t" print "
" print "
Cliquez ici pour écouter cette formation en direct
" print "
" print "
" @@ -367,7 +366,6 @@ class WebView: self.footer() - class TeleOddCast: """Manage the calls of Station and Webview to get the network and disk streams""" @@ -391,29 +389,29 @@ class TeleOddCast: form = cgi.FieldStorage() if self.odd_pid == [] and form.has_key("action") and \ - form.has_key("department") and form.has_key("course") and \ + form.has_key("department") and form.has_key("conference") and \ form.has_key("professor") and form.has_key("comment") and \ form["action"].value == "start": - self.course_dict = {'title': self.title, + self.conference_dict = {'title': self.title, 'department': form["department"].value, - 'course': form["course"].value, + 'conference': form["conference"].value, 'session': form["session"].value, 'professor': form["professor"].value, 'comment': form["comment"].value} - s = Station(self.conf_file, self.course_dict, self.lock_file) + s = Station(self.conf_file, self.conference_dict, self.lock_file) s.start() - w.stop_form(self.course_dict) + w.stop_form(self.conference_dict) elif self.odd_pid != [] and os.path.exists(self.lock_file) and not form.has_key("action"): - self.course_dict = get_course_from_lock(self.lock_file) - w.stop_form(self.course_dict) + self.conference_dict = get_conference_from_lock(self.lock_file) + w.stop_form(self.conference_dict) elif self.odd_pid != [] and form.has_key("action") and form["action"].value == "stop": if os.path.exists(self.lock_file): - self.course_dict = get_course_from_lock(self.lock_file) - s = Station(self.conf_file, self.course_dict, 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() @@ -423,7 +421,7 @@ class TeleOddCast: # Call main function. conf_file = 'etc/teleoddcast.xml' -school_file = 'etc/default_courses.xml' +school_file = 'etc/default_conferences.xml' if __name__ == '__main__': t = TeleOddCast(conf_file, school_file) diff --git a/tools.py b/tools.py index 64ca216..4e28098 100644 --- a/tools.py +++ b/tools.py @@ -68,35 +68,35 @@ def get_params_from_lock(lock_file): return params_ok def dict2tuple(dict): - len_dict = len(dict['course']) + len_dict = len(dict['conference']) if len_dict == 1: - return dict['course']['name'] + return dict['conference']['name'] else: tup = [] - for value in dict['course']: + for value in dict['conference']: tup.append(value['name']) return tup def dict2tuple_iso(dict): - len_dict = len(dict['course']) + len_dict = len(dict['conference']) if len_dict == 1: - return unicode(dict['course']['name'],'utf8').encode('iso-8859-1') + return unicode(dict['conference']['name'],'utf8').encode('iso-8859-1') else: tup = [] - for value in dict['course']: + for value in dict['conference']: tup.append(unicode(value['name'],'utf8').encode('iso-8859-1')) return tup -def get_course_from_lock(lock_file): +def get_conference_from_lock(lock_file): lockfile = open(lock_file,'r') - course = lockfile.readline() - course_l = course.split('_*_') - course_dict = {'title': course_l[0], - 'department': course_l[1], - 'course': course_l[2], - 'session': course_l[3], - 'professor': course_l[4], - 'comment': course_l[5]} + conference = lockfile.readline() + conference_l = conference.split('_*_') + conference_dict = {'title': conference_l[0], + 'department': conference_l[1], + 'conference': conference_l[2], + 'session': conference_l[3], + 'professor': conference_l[4], + 'comment': conference_l[5]} lockfile.close() - return course_dict + return conference_dict -- 2.39.5