]> git.parisson.com Git - telecaster-cgi.git/commitdiff
cleanup, fix deefuzzer path, fix get_pid
authoryomguy <yomguy@parisson.com>
Mon, 4 Jul 2011 09:14:15 +0000 (11:14 +0200)
committeryomguy <yomguy@parisson.com>
Mon, 4 Jul 2011 09:14:15 +0000 (11:14 +0200)
station.py
telecaster.py
tests.py [new file with mode: 0644]
tools/tools.py
webview.py

index 0d8155eec11974b60bf967ace2a2650678f20d9e..c16da88410906191b7586fe486a2529cc43ddace 100644 (file)
@@ -99,7 +99,11 @@ class Station(Conference):
         self.file_dir = self.output_dir + os.sep + self.ServerName
         self.uid = os.getuid()
         self.odd_pid = get_pid('^edcast_jack', self.uid)
-        self.deefuzzer_pid = get_pid('/usr/bin/deefuzzer '+self.deefuzzer_user_file, self.uid)
+        if os.path.exists('/usr/local/bin/deefuzzer'):
+            self.deefuzzer_path = '/usr/local/bin/deefuzzer'
+        elif os.path.exists('/usr/bin/deefuzzer'):
+            self.deefuzzer_path = '/usr/bin/deefuzzer'
+        self.deefuzzer_pid = get_pid(self.deefuzzer_path+' '+self.deefuzzer_user_file, self.uid)
         self.new_title = clean_string('-'.join(self.server_name)+'-'+self.session+'-'+self.professor+'-'+self.comment)
         self.short_title = clean_string('-'.join(self.conference)+'-'+self.session+'-'+self.professor+'-'+self.comment)
         self.genre = self.conf['infos']['genre']
@@ -168,13 +172,13 @@ class Station(Conference):
         os.remove(self.lock_file)
 
     def deefuzzer_stop(self):
-       if len(self.deefuzzer_pid) != 0:
-           os.system('kill -9 '+self.deefuzzer_pid[0])
+        if len(self.deefuzzer_pid) != 0:
+            os.system('kill -9 '+self.deefuzzer_pid[0])
 
     def rec_stop(self):
         if len(self.deefuzzer_pid) != 0:
-           for port in self.deefuzzer_osc_ports:
-               target = liblo.Address(int(port))
+            for port in self.deefuzzer_osc_ports:
+                target = liblo.Address(int(port))
                 liblo.send(target, '/record', 0)
 
     def mp3_convert(self):
index b68a15c044ba79d4548b57d9f0098daafc94d0af..797364198df0a5c0718fd903b2be1e9011cd5d0b 100755 (executable)
@@ -69,7 +69,11 @@ class TeleCaster:
         if not os.path.exists(self.user_dir):
             os.makedirs(self.user_dir)
         self.lock_file = self.user_dir + os.sep + 'telecaster.lock'
-
+        if os.path.exists('/usr/local/bin/deefuzzer'):
+            self.deefuzzer_path = '/usr/local/bin/deefuzzer'
+        elif os.path.exists('/usr/bin/deefuzzer'):
+            self.deefuzzer_path = '/usr/bin/deefuzzer'
+            
     def transition_head(self):
         html_file = open('telecaster_starting_head.html', 'r')
         html = html_file.read()
@@ -84,7 +88,8 @@ class TeleCaster:
 
     def main(self):
         edcast_pid = get_pid('edcast_jack', self.uid)
-        deefuzzer_pid = get_pid('/usr/bin/deefuzzer '+self.user_dir+os.sep+'deefuzzer.xml', self.uid)
+        
+        deefuzzer_pid = get_pid(self.deefuzzer_path+' '+self.user_dir+os.sep+'deefuzzer.xml', self.uid)
         writing = edcast_pid != []
         casting = deefuzzer_pid != []
         form = WebView(self.conf, version)
@@ -92,7 +97,7 @@ class TeleCaster:
         if deefuzzer_pid == [] and form.has_key("action") and \
             form.has_key("department") and form.has_key("conference") and \
             form.has_key("session") and form["action"].value == "start":
-           
+
             self.conference_dict = {'title': '',
                         'department': '',
                         'conference': '',
@@ -100,17 +105,17 @@ class TeleCaster:
                         'professor': '',
                         'comment': ''}
                         
-           for data in self.conference_dict:
-               if not form.has_key(data):
-                   self.conference_dict[data] = 'Inconnu'
-               else:
-                   value = form.getfirst(data)
-                   if '....' in value:
-                       self.conference_dict[data] = 'Inconnu'
-                   else:
-                       self.conference_dict[data] = value
-           
-           self.conference_dict['title'] = self.title
+            for data in self.conference_dict:
+                if not form.has_key(data):
+                    self.conference_dict[data] = 'Inconnu'
+                else:
+                    value = form.getfirst(data)
+                    if '....' in value:
+                        self.conference_dict[data] = 'Inconnu'
+                    else:
+                        self.conference_dict[data] = value
+
+            self.conference_dict['title'] = self.title
             s = Station(self.conf_file, self.conference_dict, self.lock_file)
             s.start()
             time.sleep(2)
@@ -123,13 +128,13 @@ class TeleCaster:
             self.logger.write_info('started')
 
         elif deefuzzer_pid and form.has_key("action") and form["action"].value == "stop":
-           self.logger.write_info('stopping')
+            self.logger.write_info('stopping')
             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 = Station(self.conf_file, self.conference_dict, self.lock_file)
                 s.stop()
-               time.sleep(2)
-               self.main()
+                time.sleep(2)
+                self.main()
 
         elif deefuzzer_pid == []:
             form.start_form(writing, casting)
@@ -138,7 +143,6 @@ class TeleCaster:
        elif deefuzzer_pid != []:
            os.system('kill -9 '+deefuzzer_pid[0])
            self.main()
-      
 
 conf_file = '/etc/telecaster/telecaster.xml'
 
diff --git a/tests.py b/tests.py
new file mode 100644 (file)
index 0000000..2247054
--- /dev/null
+++ b/tests.py
@@ -0,0 +1,23 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+    def test_basic_addition(self):
+        """
+        Tests that 1 + 1 always equals 2.
+        """
+        self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
index 776bf977b4b3d194be493de305a880b02b54e6a6..80d7371c385c2c89e74ac3462c66d81f6a98c8c8 100644 (file)
@@ -108,7 +108,7 @@ def get_pid(proc,uid):
             pid = proc.split(' ')[0]
             command = ' '.join(proc.split(' ')[1:])[:-1]
             pids.append(pid)
-    if len(pids) == 1:
+    if len(pids) < 1:
         return [] 
     else:
         return [pids[0]]
index 48cee74b40190f84bdf277654715da3ac5e505d6..a0a35870a849031f9f3a57b98e8ce17abe78cade 100644 (file)
@@ -1,6 +1,5 @@
 #!/usr/bin/python
 # -*- coding: utf-8 -*-
-# *-* coding: utf-8 *-*
 """
    telecaster
 
@@ -231,7 +230,7 @@ class WebView(FieldStorage):
         self.casting = writing
         self.writing = casting
         self.refresh = False
-       self.mount_point = 'telecaster_live.' + self.format
+        self.mount_point = 'telecaster_live.' + self.format
         self.header()
         self.javascript()
         self.sub_header()