]> git.parisson.com Git - telecaster-client.git/commitdiff
add hostname, exception for json error, tweak video tool
authoryomguy <yomguy@parisson.com>
Sun, 18 Dec 2011 16:32:09 +0000 (17:32 +0100)
committeryomguy <yomguy@parisson.com>
Sun, 18 Dec 2011 16:32:09 +0000 (17:32 +0100)
telecaster/htdocs/css/telecaster.css
telecaster/templates/telecaster/base.html
telecaster/tools/scripts/gst_video_double_shout
telecaster/tools/tools.py
telecaster/views.py

index 66e8e81bd65ee88d5fdba10a014acfcc445a3107..91bee17a9d50d339bd8b00cfcd84ac7937a6c225 100644 (file)
@@ -105,7 +105,7 @@ table.hardware {
 
 .buttons a, .buttons button{
     display:inline-block;
-    height: 20px;
+    height: 33px;
     float:left;
     margin:0 7px 0 0;
     background-color:#f5f5f5;
@@ -124,6 +124,7 @@ table.hardware {
 }
 .buttons button{
     width:auto;
+    height: 33px;
     overflow:visible;
     padding:4px 10px 3px 7px; /* IE6 */
 }
index 9f6354fa5f5f987ceff592709bb77cac20981c2b..6847a2e037cfa9debbdf01246cd957cfdf9574fe 100644 (file)
@@ -28,8 +28,13 @@ function server_status_callback(){
             tblwrapper.innerHTML = s+'</tbody></table>';
         });
     };
-    refresh();
-    setInterval(refresh,d);
+    try{
+               refresh();
+               setInterval(refresh,d);
+       }
+       catch(err){
+               setInterval(refresh,d);
+    }
 };
 server_status_callback();
 </script>
@@ -84,8 +89,8 @@ server_status_callback();
 {% block footer %}
 <div class="tools">
     <div class="buttons">
-    <button type="submit" class="button positive"><img src="{% url telecaster-images "arrow_refresh.png" %}" alt="">Refresh</button>
-    <button type="submit" name="action" value="start" class="button negative"><img src="{% url telecaster-images "stop.png" %}" alt="">Record</button>
+    <button type="submit" class="button"><img src="{% url telecaster-images "arrow_refresh.png" %}" alt="">Refresh</button>
+    <button type="submit" name="action" value="start" class="button"><img src="{% url telecaster-images "stop.png" %}" alt="">Record</button>
     <a class="button" href="http://{{ status.ip }}:{{ station.port }}/{{ station.mount_point }}"><img src="{% url telecaster-images "control_play_blue.png" %}" alt="">Play Live</a>
     <a class="button" href="/archives/"><img src="{% url telecaster-images "folder_go.png" %}" alt="">Archives</a>
     <a class="button" href="/trash/"><img src="{% url telecaster-images "bin.png" %}" alt="">Trash</a>
index 246d01ebff4bb00ad98c3341d4a623cbf100d634..50818f4f6364f79adea73da50853889b8cf6a411 100755 (executable)
@@ -1,3 +1,12 @@
 #!/bin/bash
 
-gst-launch v4l2src device=/dev/video0 ! videoscale ! video/x-raw-yuv, width=160, height=120 ! videomixer name=mix sink_1::xpos=20 sink_1::ypos=20 sink_1::alpha=0.9  ! queue ! ffmpegcolorspace ! theoraenc quality=40 ! muxout. jackaudiosrc connect=1 ! audioconvert ! audio/x-raw-int,rate=44100,channels=1,width=16 ! queue ! audioconvert ! vorbisenc ! queue ! muxout. oggmux name=muxout ! tee name=t ! queue ! filesink location="video_test.ogg" t. ! queue ! shout2send mount=/telecaster_live_video.ogg port=8000 password=source2parisson ip=127.0.0.1 v4l2src device=/dev/video1 ! videoscale ! video/x-raw-yuv, width=480, height=270 ! mix.
+gst-launch v4l2src device=/dev/video0 \
+    ! videoscale ! video/x-raw-yuv, width=160, height=120 \
+    ! videomixer name=mix sink_1::xpos=20 sink_1::ypos=20 sink_1::alpha=0.9  \
+    ! queue ! ffmpegcolorspace ! theoraenc quality=40 ! muxout. \
+    jackaudiosrc connect=1 ! audioconvert ! audio/x-raw-int,rate=44100,channels=1,width=16 \
+    ! queue ! audioconvert ! vorbisenc ! queue ! muxout. \
+    oggmux name=muxout ! tee name=t ! queue ! filesink location="video_test.ogg" t. \
+    ! queue ! shout2send mount=/telecaster_live_video.ogg port=8000 password=source2parisson ip=127.0.0.1 \
+    v4l2src device=/dev/video1 ! videoscale ! video/x-raw-yuv, width=480, height=270 ! mix.
+
index 1126dc99d04652b34eb71e659317b3b59d34faf6..d3b481e09a816ae32d91025100eb9cd7a8e0111a 100644 (file)
@@ -75,6 +75,9 @@ def get_ip_address(ifname):
         struct.pack('256s', ifname[:15])
     )[20:24])
 
+def get_hostname():
+    return socket.gethostname()
+
 def get_lines(file):
     """Get lines from a file"""
     fic = open(file,'r')
@@ -108,11 +111,11 @@ def get_pid(proc,uid):
             pid = proc.split(' ')[0]
             command = ' '.join(proc.split(' ')[1:])[:-1]
             pids.append(pid)
-    if len(pids) < 1:
-        return [] 
+    if len(pids) <= 1:
+        return []
     else:
         return [pids[0]]
-        
+
 def get_params_from_lock(lock_file):
     lockfile = open(lock_file,'r')
     params = lockfile.readline()
index 6957020c4d8dbd14a2a43b7a7a7116b6f641e78c..5f1175f4bdb00278cde3ac860020eefbd68a7e13 100644 (file)
@@ -35,11 +35,11 @@ from django.core.exceptions import ObjectDoesNotExist
 def render(request, template, data = None, mimetype = None):
     return render_to_response(template, data, context_instance=RequestContext(request),
                               mimetype=mimetype)
-                              
+
 class WebView(object):
-    
+
     hidden_fields = ['started', 'datetime_start', 'datetime_stop']
-    
+
     def __init__(self, conf_file):
         self.uid = os.getuid()
         self.user = pwd.getpwuid(os.getuid())[0]
@@ -54,11 +54,11 @@ class WebView(object):
         self.logger = Logger(self.log_file)
         self.url = self.conf['infos']['url']
         self.status = Status()
-    
+
     def index(self, request):
         stations = Station.objects.filter(started=True)
         status = self.get_server_status()
-        
+
         if stations or (status.writing or status.casting):
             template = 'telecaster/stop.html'
             # FIXME: manage multiple stations
@@ -70,7 +70,7 @@ class WebView(object):
                 time.sleep(2)
                 self.logger.write_info('stop')
                 return HttpResponseRedirect('/')
-            
+
         else:
             template = 'telecaster/start.html'
             if request.method == 'POST':
@@ -86,18 +86,18 @@ class WebView(object):
                     return HttpResponseRedirect('/')
             else:
                 station = StationForm()
-                
-        
-        return render(request, template, {'station': station, 'status': status, 
+
+
+        return render(request, template, {'station': station, 'status': status,
                                 'hidden_fields': self.hidden_fields, })
-            
+
 
     @jsonrpc_method('telecaster.get_server_status')
     def get_server_status_json(request):
         status = Status()
         status.update()
         return status.to_dict()
-        
+
     def get_server_status(self):
         status = Status()
         status.update()
@@ -111,18 +111,18 @@ class WebView(object):
         else:
             station = {}
         return station
-        
+
 class Status(object):
-        
+
     interfaces = ['eth0', 'eth1', 'eth2', 'eth0-eth2','eth3']
     acpi_states = {0: 'battery', 1: 'battery', 2: 'AC'}
-    
+
     def __init__(self):
         self.acpi = acpi.Acpi()
         self.uid = os.getuid()
         self.user = pwd.getpwuid(os.getuid())[0]
         self.user_dir = '/home' + os.sep + self.user + os.sep + '.telecaster'
-        
+
     def update(self):
         self.acpi.update()
         try:
@@ -131,26 +131,26 @@ class Status(object):
             self.temperature = 'N/A'
         self.get_ids()
         self.get_hosts()
-    
+
     def to_dict(self):
         status = [
-          {'id': 'acpi_state','class': 'default', 'value': self.acpi_states[self.acpi.charging_state()], 'label': 'Power'},  
-          {'id': 'acpi_percent', 'class': 'default', 'value': str(self.acpi.percent()), 'label': 'Battery Charge'}, 
-          {'id': 'temperature', 'class': 'default', 'value': self.temperature, 'label': 'Temperature'}, 
-          {'id': 'jack_state', 'class': 'default', 'value': self.jacking, 'label': 'Jack server'}, 
-          {'id': 'url', 'class': 'default', 'value': self.url, 'label': 'Name'}, 
-          {'id': 'ip', 'class': 'default', 'value': self.ip, 'label': 'IP address'},  
-          {'id': 'encoder_state','class': 'default', 'value': self.writing, 'label': 'Encoder'}, 
-          {'id': 'casting', 'class': 'default', 'value': self.casting, 'label': 'Broadcasting'},  
-          {'id': 'writing', 'class': 'default', 'value': self.writing, 'label': 'Recording'},  
+          {'id': 'acpi_state','class': 'default', 'value': self.acpi_states[self.acpi.charging_state()], 'label': 'Power'},
+          {'id': 'acpi_percent', 'class': 'default', 'value': str(self.acpi.percent()), 'label': 'Battery Charge'},
+          {'id': 'temperature', 'class': 'default', 'value': self.temperature, 'label': 'Temperature'},
+          {'id': 'jack_state', 'class': 'default', 'value': self.jacking, 'label': 'Jack server'},
+          {'id': 'name', 'class': 'default', 'value': self.name, 'label': 'Name'},
+          {'id': 'ip', 'class': 'default', 'value': self.ip, 'label': 'IP address'},
+          {'id': 'encoder_state','class': 'default', 'value': self.writing, 'label': 'Encoder'},
+          {'id': 'casting', 'class': 'default', 'value': self.casting, 'label': 'Broadcasting'},
+          {'id': 'writing', 'class': 'default', 'value': self.writing, 'label': 'Recording'},
           ]
-                  
+
         for stat in status:
             if stat['value'] == False:
                 stat['class'] = 'warning'
 
         return status
-        
+
     def get_hosts(self):
         ip = ''
         for interface in self.interfaces:
@@ -160,10 +160,11 @@ class Status(object):
                     self.ip = ip
                 break
             except:
-                self.ip = 'localhost'
+                self.ip = '127.0.0.1'
         self.url = 'http://' + self.ip
-        
-    def get_ids(self):  
+        self.name = get_hostname()
+
+    def get_ids(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)
         jackd_pid = get_pid('jackd', self.uid)