From 126202551d10272a440f5b8bde2c14151216f44d Mon Sep 17 00:00:00 2001 From: yomguy Date: Thu, 12 Jul 2012 22:58:22 +0200 Subject: [PATCH] various bugfix infos, status, etc.. --- telecaster/models.py | 25 +++++++++++++---------- telecaster/tools/status.py | 41 +++++++++++++++++++++++++++----------- telecaster/tools/tools.py | 14 ++++++++----- 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/telecaster/models.py b/telecaster/models.py index 755dffe..6b11b36 100644 --- a/telecaster/models.py +++ b/telecaster/models.py @@ -104,11 +104,15 @@ class Station(Model): def description(self): return self.conference.description + @property + def slug(self): + return self.conference.slug + def setup(self, conf_file): self.course = self.conference.course self.department = self.course.department.name self.organization = self.course.department.organization.name - self.mount_point = self.conference.slug + self.mount_point = self.slug self.conf = xml2dict(conf_file) self.date = datetime.datetime.now().strftime("%Y") @@ -118,7 +122,6 @@ class Station(Model): self.uid = os.getuid() self.user = pwd.getpwuid(self.uid)[0] self.user_dir = '/home' + os.sep + self.user + os.sep + '.telecaster' - self.deefuzzer_user_file = self.user_dir + os.sep + 'station_' + self.public_id + '.xml' self.encoder = 'TeleCaster system by Parisson' self.save() @@ -138,16 +141,19 @@ class Station(Model): def deefuzzer_setup(self): for station in self.conf['deefuzzer']['station']: - output_dir = os.sep.join([station['record']['dir'], - self.date, self.department, - unicode(self.course), self.public_id]) + output_dir = os.sep.join([self.date, self.department, + self.course.code + spacer + self.conference.course_type.name, + self.public_id + ]) if not os.path.exists(output_dir): os.makedirs(output_dir) station['infos']['short_name'] = self.mount_point - station['infos']['name'] = self.description - station['infos']['description'] = self.description + station['infos']['name'] = self.slug + station['infos']['description'] = self.slug station['record']['dir'] = output_dir - station['relay']['author'] = unicode(self.conference.professor) + station['relay']['author'] = unicode(self.conference.professor.user.username) + self.deefuzzer_user_file = self.user_dir + os.sep + 'station_' + \ + station['media']['format'] + '.xml' self.deefuzzer_xml = dicttoxml(self.conf) def deefuzzer_write_conf(self): @@ -158,7 +164,7 @@ class Station(Model): def deefuzzer_start(self): command = 'deefuzzer ' + self.deefuzzer_user_file + ' > /dev/null &' os.system(command) - time.sleep(1) + time.sleep(0.5) self.pid = get_pid('deefuzzer', args=self.deefuzzer_user_file) self.save() @@ -214,7 +220,6 @@ class Station(Model): self.started = False self.datetime_stop = datetime.datetime.now() self.rec_stop() - time.sleep(1) self.deefuzzer_stop() self.save() diff --git a/telecaster/tools/status.py b/telecaster/tools/status.py index 0c7d1c2..64fa5bb 100644 --- a/telecaster/tools/status.py +++ b/telecaster/tools/status.py @@ -66,10 +66,15 @@ class Status(object): {'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': 'Charge (%)'}, {'id': 'temperature', 'class': 'default', 'value': self.temperature, 'label': 'Temperature'}, - {'id': 'jack_state', 'class': 'default', 'value': self.jacking, 'label': 'Jack server'}, - {'id': 'encoder_state','class': 'default', 'value': self.writing, 'label': 'Encoder'}, - {'id': 'casting', 'class': 'default', 'value': self.casting, 'label': 'Broadcaster'}, - {'id': 'writing', 'class': 'default', 'value': self.writing, 'label': 'Recorder'}, + {'id': 'jackd', 'class': 'default', 'value': self.jacking, 'label': 'Jack server'}, + {'id': 'audio_encoding','class': 'default', + 'value': self.audio_encoding, 'label': 'Audio encoding'}, + {'id': 'video_encoding','class': 'default', + 'value': self.video_encoding, 'label': 'Video encoding'}, + {'id': 'audio_streaming', 'class': 'default', + 'value': self.audio_streaming, 'label': 'Audio streaming'}, + {'id': 'video_streaming', 'class': 'default', + 'value': self.video_streaming, 'label': 'Video streaming'}, ] for stat in status: @@ -92,18 +97,30 @@ class Status(object): self.name = get_hostname() def get_ids(self): + if get_pid('jackd', args=False): + self.jacking = True + else: + self.jacking = False + if get_pid('edcast_jack', args=False): - self.writing = True + self.audio_encoding = True else: - self.writing = False + self.audio_encoding = False - if get_pid('deefuzzer', args=self.user_dir+os.sep+'deefuzzer.xml'): - self.casting = True + if get_pid('gst-launch-0.10', args=False): + self.video_encoding = True else: - self.casting = False + self.video_encoding = False - if get_pid('jackd', args=False): - self.jacking = True + audio_pid = get_pid('deefuzzer', args=self.user_dir+os.sep+'station_mp3.xml') + video_pid = get_pid('deefuzzer', args=self.user_dir+os.sep+'station_webm.xml') + + if audio_pid: + self.audio_streaming = True else: - self.jacking = False + self.audio_streaming = False + if video_pid: + self.video_streaming = True + else: + self.video_streaming = False diff --git a/telecaster/tools/tools.py b/telecaster/tools/tools.py index a20eaa0..2f1f672 100644 --- a/telecaster/tools/tools.py +++ b/telecaster/tools/tools.py @@ -72,11 +72,15 @@ class SubProcessPipe: def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - return socket.inet_ntoa(fcntl.ioctl( - s.fileno(), - 0x8915, # SIOCGIFADDR - struct.pack('256s', ifname[:15]) - )[20:24]) + try: + ip = socket.inet_ntoa(fcntl.ioctl( + s.fileno(), + 0x8915, # SIOCGIFADDR + struct.pack('256s', ifname[:15]) + )[20:24]) + except: + ip = '127.0.0.1' + return ip def get_hostname(): return socket.gethostname() -- 2.39.5