From: yomguy Date: Sun, 15 Jul 2012 21:53:24 +0000 (+0200) Subject: fix output_dir for stations, add rsync backup scripts, fix wrong IPs.. X-Git-Tag: 0.9~62 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b4c28d3b0facb084d1dc1e987be6e700e895a70b;p=telecaster-client.git fix output_dir for stations, add rsync backup scripts, fix wrong IPs.. --- diff --git a/telecaster/management/__init__.py b/telecaster/management/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/telecaster/management/commands/__init__.py b/telecaster/management/commands/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/telecaster/management/commands/telecaster-rsync-archives.py b/telecaster/management/commands/telecaster-rsync-archives.py new file mode 100644 index 0000000..f4c4196 --- /dev/null +++ b/telecaster/management/commands/telecaster-rsync-archives.py @@ -0,0 +1,34 @@ +from optparse import make_option +from django.conf import settings +from django.core.management.base import BaseCommand, CommandError +from django.contrib.auth.models import User +from django.template.defaultfilters import slugify +from telemeta.models import * +from telemeta.util.unaccent import unaccent +from teleforma.models import * +from telecaster.models import * +from telecaster.tools import * +import os + +class Command(BaseCommand): + help = "Synchronize local archives with backup server" + admin_email = 'webmaster@parisson.com' + archives = settings.MEDIA_ROOT + server = settings.TELECASTER_RSYNC_SERVER + log = settings.TELECASTER_RSYNC_LOG + logger = Logger(log) + command = 'rsync -aq ' + + def handle(self, *args, **options): + stations = Station.objects.filter(started=True) + ids = [station.public_id for station in stations] + if ids: + for id in ids: + self.command += '--exclude=%s ' % id + self.command += self.archives + ' ' + self.server + try: + os.system(self.command) + self.logger.write_info(self.command) + except: + self.logger.write_error('NOT rsynced') + \ No newline at end of file diff --git a/telecaster/models.py b/telecaster/models.py index b9c65d6..481ef30 100644 --- a/telecaster/models.py +++ b/telecaster/models.py @@ -38,7 +38,7 @@ import os import pwd import datetime import time -import urllib +import urllib2 import liblo from tools import * @@ -133,28 +133,26 @@ class Station(Model): self.osc.add(osc[0]) else: self.osc.create(host='127.0.0.1', port=port) - -# if station['server']['host'] == 'localhost' or station['server']['host'] == '127.0.0.1': -# self.conf['play_port'] = station['server']['port'] -# else: -# self.conf['play_port'] = '8000' - + def deefuzzer_setup(self): - station = self.conf['deefuzzer']['station'][0] - output_dir = station['record']['dir'] - if output_dir[-1] != os.sep: - output_dir += os.sep - 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) + self.output_dirs = [] + self.urls = [] for station in self.conf['deefuzzer']['station']: + if station['record']['mode'] != '0': + output_dir = station['record']['dir'] + if output_dir[-1] != os.sep: + output_dir += os.sep + 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['record']['dir'] = output_dir station['infos']['short_name'] = self.mount_point station['infos']['name'] = self.slug station['infos']['description'] = self.slug - station['record']['dir'] = output_dir + station['relay']['author'] = unicode(self.conference.professor.user.username) self.deefuzzer_user_file = self.user_dir + os.sep + 'station_' + \ station['media']['format'] + '.xml' @@ -212,7 +210,10 @@ class Station(Model): #tag = tags.__dict__['COMMENT'] #audio.add(COM(encoding=3, text=self.comment)) audio.save() - + + def get_snapshot(self): + pass + def start(self): self.started = True self.deefuzzer_setup() diff --git a/telecaster/tools/tools.py b/telecaster/tools/tools.py index 2f1f672..1d0921f 100644 --- a/telecaster/tools/tools.py +++ b/telecaster/tools/tools.py @@ -72,14 +72,11 @@ class SubProcessPipe: def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - try: - ip = socket.inet_ntoa(fcntl.ioctl( + 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(): diff --git a/telecaster/views.py b/telecaster/views.py index ea8f11c..51a2da3 100644 --- a/telecaster/views.py +++ b/telecaster/views.py @@ -44,8 +44,6 @@ def get_host(request): class StatusView(object): - - @jsonrpc_method('telecaster.get_server_status') def get_server_status(request): status = Status()