]> git.parisson.com Git - telecaster-client.git/commitdiff
fix output_dir for stations, add rsync backup scripts, fix wrong IPs..
authoryomguy <yomguy@parisson.com>
Sun, 15 Jul 2012 21:53:24 +0000 (23:53 +0200)
committeryomguy <yomguy@parisson.com>
Sun, 15 Jul 2012 21:53:24 +0000 (23:53 +0200)
telecaster/management/__init__.py [new file with mode: 0644]
telecaster/management/commands/__init__.py [new file with mode: 0644]
telecaster/management/commands/telecaster-rsync-archives.py [new file with mode: 0644]
telecaster/models.py
telecaster/tools/tools.py
telecaster/views.py

diff --git a/telecaster/management/__init__.py b/telecaster/management/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/telecaster/management/commands/__init__.py b/telecaster/management/commands/__init__.py
new file mode 100644 (file)
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 (file)
index 0000000..f4c4196
--- /dev/null
@@ -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
index b9c65d63af5ea8dcf55b27c08366f851563b1fe3..481ef303483d672c31fd1fdcd892e37799be2b48 100644 (file)
@@ -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()
index 2f1f6729486bceb93472dc1c69f7321d0fd0be2a..1d0921f525306804603a2860f92219947bcbe57b 100644 (file)
@@ -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():
index ea8f11c1b727bafad632795998316cba63e3179f..51a2da374b80c7e37a9398407844a3df8e36adff 100644 (file)
@@ -44,8 +44,6 @@ def get_host(request):
 
 class StatusView(object):
 
-
-
     @jsonrpc_method('telecaster.get_server_status')
     def get_server_status(request):
         status = Status()