From: yomguy <> Date: Wed, 28 Nov 2007 10:45:07 +0000 (+0000) Subject: Change TeleOddCast to Station, change main() X-Git-Tag: 0.9~343 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=494c44a5a2463ca77861308ff8e7acb41f47714f;p=telecaster-client.git Change TeleOddCast to Station, change main() --- diff --git a/teleoddcast.cfg b/teleoddcast.cfg index aeb7541..80b2e8b 100644 --- a/teleoddcast.cfg +++ b/teleoddcast.cfg @@ -1,7 +1,7 @@ Server=localhost Port=8000 ServerPassword=source2parisson -ServerMountpoint=/My_best_funky_station_-_AE_-_Penal_Cours.ogg +ServerMountpoint=/My_best_funky_station_-_AE_-_Commercial_Correctio.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_best_funky_station_-_AE_-_Penal_Cours_-_1 -ServerDescription=My_best_funky_station_-_AE_-_Penal_Cours_-_1_-_zad_-_azdf +ServerName=My_best_funky_station_-_AE_-_Commercial_Correctio_-_1 +ServerDescription=My_best_funky_station_-_AE_-_Commercial_Correctio_-_1_-_zad_-_azdzaddza ServerGenre=Teaching #Advanced Settings LogLevel=1 diff --git a/teleoddcast.py b/teleoddcast.py index d1fdfde..1ee07f5 100755 --- a/teleoddcast.py +++ b/teleoddcast.py @@ -47,7 +47,7 @@ class Course: return self.title, self.department, self.course, self.session, self.professor, self.comment -class TeleOddCast(Course): +class Station(Course): """Control the Oddcastv3-jack thread which send audio data to the icecast server and the Streamripper thread which write audio on the hard disk""" @@ -309,55 +309,64 @@ class WebView: self.colophon() self.footer() -def main(): - """Main function""" - conf_file = 'teleoddcast.xml' - school_file = 'pre-barreau.xml' - - conf_t = xml2dict(conf_file) - conf = conf_t['teleoddcast'] - title = conf['infos']['name'] - root_dir = conf['server']['root_dir'] - lock_file = root_dir + os.sep + conf['server']['lock_file'] - odd_conf_file = conf['server']['lock_file'] - title = conf['infos']['name'] - - uid = os.getuid() - odd_pid = get_pid('^oddcastv3 -n [^LIVE]', uid) - - w = WebView(school_file) - 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": - - course_dict = {'title': title, - 'department': form["department"].value, - 'course': form["course"].value, - 'session': form["session"].value, - 'professor': form["professor"].value, - 'comment': form["comment"].value} - - t = TeleOddCast(conf_file, course_dict, lock_file) - t.start() - w.stop_form(course_dict) + + +class TeleOddCast: + + def __init__(self, conf_file, school_file): + """Main function""" + self.conf_file = conf_file + self.school_file = school_file + conf_t = xml2dict(self.conf_file) + self.conf = conf_t['teleoddcast'] + self.title = self.conf['infos']['name'] + self.root_dir = self.conf['server']['root_dir'] + self.lock_file = self.root_dir + os.sep + self.conf['server']['lock_file'] + self.odd_conf_file = self.conf['server']['lock_file'] + self.title = self.conf['infos']['name'] + self.uid = os.getuid() + self.odd_pid = get_pid('^oddcastv3 -n [^LIVE]', self.uid) + + def main(self): + w = WebView(self.school_file) + form = cgi.FieldStorage() - elif odd_pid != [] and os.path.exists(lock_file) and not form.has_key("action"): - course_dict = get_course_from_lock(lock_file) - w.stop_form(course_dict) + if self.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": + + self.course_dict = {'title': self.title, + 'department': form["department"].value, + 'course': form["course"].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.start() + w.stop_form(self.course_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) + + 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) + s.stop() + w.start_form() - elif odd_pid != [] and form.has_key("action") and form["action"].value == "stop": - if os.path.exists(lock_file): - course_dict = get_course_from_lock(lock_file) - t = TeleOddCast(conf_file, course_dict, lock_file) - t.stop() - w.start_form() + elif self.odd_pid == []: + w.start_form() - elif odd_pid == []: - w.start_form() # Call main function. +conf_file = 'teleoddcast.xml' +school_file = 'pre-barreau.xml' + if __name__ == '__main__': - main() + t = TeleOddCast(conf_file, school_file) + t.main()