From: yomguy Date: Sun, 18 Dec 2011 16:32:09 +0000 (+0100) Subject: add hostname, exception for json error, tweak video tool X-Git-Tag: 1.0~65 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=a839ddce240f2eecb3fbe837c0eaae8a136c8640;p=telecaster-server.git add hostname, exception for json error, tweak video tool --- diff --git a/telecaster/htdocs/css/telecaster.css b/telecaster/htdocs/css/telecaster.css index 66e8e81..91bee17 100644 --- a/telecaster/htdocs/css/telecaster.css +++ b/telecaster/htdocs/css/telecaster.css @@ -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 */ } diff --git a/telecaster/templates/telecaster/base.html b/telecaster/templates/telecaster/base.html index 9f6354f..6847a2e 100644 --- a/telecaster/templates/telecaster/base.html +++ b/telecaster/templates/telecaster/base.html @@ -28,8 +28,13 @@ function server_status_callback(){ tblwrapper.innerHTML = s+''; }); }; - refresh(); - setInterval(refresh,d); + try{ + refresh(); + setInterval(refresh,d); + } + catch(err){ + setInterval(refresh,d); + } }; server_status_callback(); @@ -84,8 +89,8 @@ server_status_callback(); {% block footer %}
- - + + Play Live Archives Trash diff --git a/telecaster/tools/scripts/gst_video_double_shout b/telecaster/tools/scripts/gst_video_double_shout index 246d01e..50818f4 100755 --- a/telecaster/tools/scripts/gst_video_double_shout +++ b/telecaster/tools/scripts/gst_video_double_shout @@ -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. + diff --git a/telecaster/tools/tools.py b/telecaster/tools/tools.py index 1126dc9..d3b481e 100644 --- a/telecaster/tools/tools.py +++ b/telecaster/tools/tools.py @@ -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() diff --git a/telecaster/views.py b/telecaster/views.py index 6957020..5f1175f 100644 --- a/telecaster/views.py +++ b/telecaster/views.py @@ -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)