]> git.parisson.com Git - telecaster-server.git/commitdiff
Get started
authoryomguy <>
Mon, 26 Nov 2007 18:33:43 +0000 (18:33 +0000)
committeryomguy <>
Mon, 26 Nov 2007 18:33:43 +0000 (18:33 +0000)
teleoddcast.cfg
teleoddcast.py
teleoddcast.xml
tools.py

index 539d6b5fa04a929fd6f1b162f1030a63196e8c29..10217762b2a87b6a66bdd8d4ac3a868af42f773c 100644 (file)
@@ -1,7 +1,7 @@
 Server=localhost
 Port=8000
 ServerPassword=source2parisson
-ServerMountpoint=/My_best_funky_station_-_AE_-_Civil_Correction.ogg
+ServerMountpoint=/My_best_funky_station_-_AE_-_Adm_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=My_best_funky_station_-_AE_-_Civil_Correction_-_1
-ServerDescription=My_best_funky_station_-_AE_-_Civil_Correction_-_1_-_sf_-_ze
+ServerName=My_best_funky_station_-_AE_-_Adm_Correction_-_1
+ServerDescription=My_best_funky_station_-_AE_-_Adm_Correction_-_1_-_zeaf_-_zef
 ServerGenre=Teaching
 #Advanced Settings
 LogLevel=1
index 64635682a53eb487e18bda662d9523fb03c80329..ed570dbc1353109e8e63f3275be3f7ea7f419057 100755 (executable)
@@ -36,6 +36,7 @@ class Course:
     """A course in a class room"""
     
     def __init__(self, dict):
+        self.title = dict['title']
         self.department = dict['department']
         self.course = dict['course']
         self.session = dict['session']
@@ -50,11 +51,10 @@ class TeleOddCast(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"""
     
-    def __init__(self, conf_file, course_dict):
+    def __init__(self, conf_file, course_dict, lock_file):
         Course.__init__(self, course_dict)
         self.conf = xml2dict(conf_file)
         self.conf = self.conf['teleoddcast']
-        self.title = self.conf['infos']['name']
         self.root_dir = self.conf['server']['root_dir']
         self.media_dir = self.conf['media']['dir']
         self.host = self.conf['server']['host']
@@ -69,7 +69,7 @@ class TeleOddCast(Course):
         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.lock_file = self.root_dir + os.sep + self.conf['server']['lock_file']
         self.filename = self.ServerDescription + '.ogg'
         self.uid = os.getuid()
         self.odd_pid = get_pid('^oddcastv3 -n [^LIVE]', self.uid)
@@ -133,6 +133,7 @@ class TeleOddCast(Course):
         os.system('kill -9 ' + self.odd_pid[0])
         
     def stop_rip(self):
+        print self.rip_pid[0]
         os.system('kill -9 ' + self.rip_pid[0])
         time.sleep(1)
         date = datetime.datetime.now().strftime("%Y")
@@ -314,8 +315,15 @@ def main():
     """Main function"""
     conf_file = 'teleoddcast.xml'
     school_file = 'pre-barreau.xml'
-    odd_conf_file = 'teleoddcast.cfg'
-    lock_file = 'teleoddcast.lock'
+    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)
 
@@ -326,25 +334,25 @@ def main():
            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 = {'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)
+        t = TeleOddCast(conf_file, course_dict, lock_file)
         t.start()
         w.stop_form(course_dict)
         
     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()
+        course_dict = get_course_from_lock(lock_file)
        w.stop_form(course_dict)
 
     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):
-            title,department,course,session,professor,comment = t.get_info()
+            course_dict = get_course_from_lock(lock_file)
+        t = TeleOddCast(conf_file, course_dict, lock_file)
         t.stop()
        w.start_form()
 
index 4cd2dbd252de8f5913a690b0ada6cce011a1277f..82663a10b06207145b4052cf9953097e54a5410e 100644 (file)
@@ -12,8 +12,9 @@
             <port>8000</port>
             <sourcepassword>source2parisson</sourcepassword>
             <public>1</public>
-            <root_dir>/var/www/cgi-bin/</root_dir>
+            <root_dir>/var/www/teleoddcast/</root_dir>
             <odd_conf_file>teleoddcast.cfg</odd_conf_file>
+            <lock_file>teleoddcast.lock</lock_file>
         </server>
         <media>
             <dir>/tmp/media</dir>
index fc80489aee0577e062c61f9f2f9fb4c4476df234..ff83f9ad935f5f45fbd56ca69ee8554fe4f28cf5 100644 (file)
--- a/tools.py
+++ b/tools.py
@@ -76,3 +76,16 @@ def dict2tuple(dict):
             tup.append(value['name'])
         return tup
 
+def get_course_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]}
+    lockfile.close()
+    return course_dict
+