Author: duncan
Date: Sun Oct 29 12:02:48 2006
New Revision: 8506

Modified:
   branches/rel-1-6/freevo/ChangeLog
   branches/rel-1-6/freevo/src/helpers/recordserver.py

Log:
Updated for latest bug fixes

Modified: branches/rel-1-6/freevo/ChangeLog
==============================================================================
--- branches/rel-1-6/freevo/ChangeLog   (original)
+++ branches/rel-1-6/freevo/ChangeLog   Sun Oct 29 12:02:48 2006
@@ -6,8 +6,16 @@
 Note
 ----
 Items marked (X#nnnnnnn) have a tracker item see:
-X is (B)ugs or (F)eature request, #nnnnnnn is the tracker number
-http://sourceforge.net/tracker/?group_id=46652
+X is the category and #nnnnnnn is the tracker number.
+(B)ugs             http://sourceforge.net/tracker/?group_id=46652&atid=446895
+(F)eature requests http://sourceforge.net/tracker/?group_id=46652&atid=446898
+
+
+Release 1.6.1 (2006-??-??):
+---------------------------
+
+ * Fixed detached music player when the plug-in mplayervis is enabled 
(B#1582048)
+ * Fixed IMDB parser, the title should not work (B#1586579)
 
 Release 1.6.0 (2006-10-31):
 ---------------------------

Modified: branches/rel-1-6/freevo/src/helpers/recordserver.py
==============================================================================
--- branches/rel-1-6/freevo/src/helpers/recordserver.py (original)
+++ branches/rel-1-6/freevo/src/helpers/recordserver.py Sun Oct 29 12:02:48 2006
@@ -27,7 +27,7 @@
 # -----------------------------------------------------------------------
 
 
-import sys, string, random, time, os, re, pwd, stat
+import sys, string, random, time, os, re, pwd, stat, threading
 import config
 from util import vfs
 
@@ -46,7 +46,6 @@
 from twisted.internet.app import Application
 from twisted.internet import reactor
 from twisted.python import log
-
 from util.marmalade import jellyToXML, unjellyFromXML
 
 import rc
@@ -64,7 +63,6 @@
 from util.videothumb import snapshot
 from event import *
 
-dbglvl=1
 
 def _debug_(text, level=1):
     if config.DEBUG >= level:
@@ -103,12 +101,18 @@
 class RecordServer(xmlrpc.XMLRPC):
 
     def __init__(self):
+        self.lock = threading.Lock()
         self.fc = FreevoChannels()
         # XXX: In the future we should have one lock per VideoGroup.
         self.tv_lock_file = None
         self.vg = None
 
 
+    def isRecording(self):
+        _debug_('in isRecording', 3)
+        return glob.glob(config.FREEVO_CACHEDIR + '/record.*') and TRUE or 
FALSE
+
+
     def progsTimeCompare(self, first, second):
         t1 = first.split(':')[-1]
         t2 = second.split(':')[-1]
@@ -118,30 +122,28 @@
             pass
         return 0
 
-    def findNextProgram(self):
-        _debug_('in findNextProgram', dbglvl+3)
-
-        progs = self.getScheduledRecordings().getProgramList()
-        now = time.time()
 
+    def findNextProgram(self):
+        _debug_('in findNextProgram', 3)
         next_program = None
-        proglist = list(progs)
+        now = time.time()
+        proglist = list(self.getScheduledRecordings().getProgramList())
         proglist.sort(self.progsTimeCompare)
         for progitem in proglist:
             prog = progs[progitem]
-            _debug_('%s' % (prog), dbglvl+1)
+            _debug_('%s' % (prog), 2)
 
             try:
                 recording = prog.isRecording
             except:
-                recording = False
+                recording = FALSE
             _debug_('%s: recording=%s' % (prog.title, recording))
 
             if now >= prog.stop + config.TV_RECORD_PADDING_POST:
                 _debug_('%s: prog.stop=%s, now=%s' % (prog.title, \
-                    time.localtime(prog.stop+config.TV_RECORD_PADDING_POST), 
now), dbglvl+1)
+                    time.localtime(prog.stop+config.TV_RECORD_PADDING_POST), 
now), 2)
                 continue
-            _debug_('%s: prog.stop=%s' % (prog.title, 
time.localtime(prog.stop)), dbglvl)
+            _debug_('%s: prog.stop=%s' % (prog.title, 
time.localtime(prog.stop)))
 
             if not recording:
                 next_program = prog
@@ -149,10 +151,10 @@
 
         self.next_program = next_program
         if next_program == None:
-            _debug_('No program scheduled to record', dbglvl)
+            _debug_('No program scheduled to record')
             return None
 
-        _debug_('%s' % (next_program), dbglvl)
+        _debug_('%s' % (next_program))
         return next_program
 
 
@@ -163,7 +165,7 @@
             real player running test, check /dev/videoX.
             this could go into the upsoon client
         '''
-        _debug_('in isPlayerRunning', dbglvl+3)
+        _debug_('in isPlayerRunning', 3)
         return (os.path.exists(config.FREEVO_CACHEDIR + '/playing'))
 
     # note: add locking and r/rw options to get/save funs
@@ -172,12 +174,12 @@
         scheduledRecordings = None
 
         if os.path.isfile(config.TV_RECORD_SCHEDULE):
-            _debug_('GET: reading cached file (%s)' % 
config.TV_RECORD_SCHEDULE)
+            _debug_('GET: reading cached file (%s)' % 
config.TV_RECORD_SCHEDULE, 2)
             if hasattr(self, 'scheduledRecordings_cache'):
                 mod_time, scheduledRecordings = self.scheduledRecordings_cache
                 try:
                     if os.stat(config.TV_RECORD_SCHEDULE)[stat.ST_MTIME] == 
mod_time:
-                        _debug_('Return cached data')
+                        _debug_('Return cached data', 2)
                         return scheduledRecordings
                 except OSError:
                     pass
@@ -257,7 +259,8 @@
     
         for chan in guide.chan_list:
             if prog.channel_id == chan.id:
-                _debug_('scheduleRecording: prog.channel_id="%s" chan.id="%s" 
chan.tunerid="%s"' % (String(prog.channel_id), String(chan.id), 
String(chan.tunerid)))
+                _debug_('scheduleRecording: prog.channel_id="%s" chan.id="%s" 
chan.tunerid="%s"' %
+                    (String(prog.channel_id), String(chan.id), 
String(chan.tunerid)))
                 prog.tunerid = chan.tunerid
     
         scheduledRecordings = self.getScheduledRecordings()
@@ -335,7 +338,8 @@
                 _debug_('CHANNEL MATCH: %s' % ch.id)
                 for prog in ch.programs:
                     if start == '%s' % prog.start:
-                        _debug_('PROGRAM MATCH: %s' % prog.decode().title)
+                        #_debug_('PROGRAM MATCH 1: %s' % 
prog.title.encode('ascii', 'replace'))
+                        _debug_('PROGRAM MATCH 1: %s' % prog.decode().title)
                         return (TRUE, prog.decode())
 
         return (FALSE, 'prog not found')
@@ -370,12 +374,14 @@
                         # rating.  Suggestions are welcome.
                         if 'MPAA' in prog.decode().getattr('ratings').keys():
                             matches.append(prog.decode())
-                            _debug_('PROGRAM MATCH: %s' % prog.decode())
+                            #_debug_('PROGRAM MATCH 2: %s' % 
prog.title.encode('ascii', 'replace'))
+                            _debug_('PROGRAM MATCH 2: %s' % prog.decode())
                     else:
                         # We should never get here if not find and not 
                         # movies_only.
                         matches.append(prog.decode())
-                        _debug_('PROGRAM MATCH: %s' % prog.decode())
+                        #_debug_('PROGRAM MATCH 3: %s' % 
prog.title.encode('ascii', 'replace'))
+                        _debug_('PROGRAM MATCH 3: %s' % prog.decode())
                 if len(matches) >= max_results:
                     break
 
@@ -415,7 +421,7 @@
 
         now = time.time()
         for prog in progs.values():
-            _debug_('checkToRecord: progloop=%s' % String(prog))
+            _debug_('checkToRecord: progloop=%s' % String(prog), 2)
 
             try:
                 recording = prog.isRecording
@@ -424,12 +430,15 @@
 
             if (prog.start - config.TV_RECORD_PADDING_PRE) <= now \
                    and (prog.stop + config.TV_RECORD_PADDING_POST) >= now \
-                   and recording == FALSE:
+                   and not recording:
                 # just add to the 'we want to record this' list
                 # then end the loop, and figure out which has priority,
                 # remember to take into account the full length of the shows
                 # and how much they overlap, or chop one short
-                duration = int((prog.stop + config.TV_RECORD_PADDING_POST ) - 
now - 10)
+                print 'DJW: prog.stop:', prog.stop
+                print 'int(prog.stop + config.TV_RECORD_PADDING_POST)', 
int(prog.stop + config.TV_RECORD_PADDING_POST)
+                duration = int((prog.stop + config.TV_RECORD_PADDING_POST) - 
now - 10)
+                print 'DJW: duration:', duration
                 if duration < 10:
                     return 
 
@@ -440,6 +449,12 @@
                         # check if the new prog is a favorite and the current 
running is
                         # not. If so, the user manually added something, we 
guess it
                         # has a higher priority.
+
+                        print 'DJW: prog:', prog
+                        print 'DJW: self.isProgAFavorite(prog)[0]', 
self.isProgAFavorite(prog)[0]
+                        print 'DJW: 
self.isProgAFavorite(currently_recording)[0]', 
self.isProgAFavorite(currently_recording)[0]
+                        print 'DJW: prog.stop+config.TV_RECORD_PADDING_POST', 
prog.stop+config.TV_RECORD_PADDING_POST
+                        print 'DJW: now:', now
                         if self.isProgAFavorite(prog)[0] and \
                            not self.isProgAFavorite(currently_recording)[0] 
and \
                            prog.stop + config.TV_RECORD_PADDING_POST > now:
@@ -449,7 +464,7 @@
                                          tv_util.getKey(currently_recording))
                         plugin.getbyname('RECORD').Stop()
                         time.sleep(5)
-                        _debug_('CALLED RECORD STOP 1')
+                        _debug_('CALLED RECORD STOP 1: %s' % 
String(currently_recording))
                     else:
                         # at this moment we must be in the pre-record padding
                         if currently_recording.stop - 10 <= now:
@@ -461,12 +476,12 @@
                                        config.TV_RECORD_PADDING_POST) - \
                                       (prog.start - 
config.TV_RECORD_PADDING_PRE)
                             if overlap <= ((config.TV_RECORD_PADDING_PRE +
-                                           config.TV_RECORD_PADDING_POST)/4):
+                                            config.TV_RECORD_PADDING_POST)/4):
                                 sr.removeProgram(currently_recording, 
                                                  
tv_util.getKey(currently_recording))
                                 plugin.getbyname('RECORD').Stop()
                                 time.sleep(5)
-                                _debug_('CALLED RECORD STOP 2')
+                                _debug_('CALLED RECORD STOP 2: %s' % 
String(currently_recording))
                             else: 
                                 delay_recording = TRUE
                         else: 
@@ -486,7 +501,7 @@
         for prog in progs.values():
             # If the program is over remove the entry.
             if ( prog.stop + config.TV_RECORD_PADDING_POST) < now:
-                _debug_('found a program to clean')
+                _debug_('found a program to clean: %s' % String(prog))
                 cleaned = TRUE
                 del progs[tv_util.getKey(prog)]
 
@@ -495,16 +510,16 @@
             self.saveScheduledRecordings(sr)
 
         if rec_prog:
-            _debug_('start recording')
+            _debug_('start recording: %s' % String(rec_prog))
             self.record_app = plugin.getbyname('RECORD')
 
             if not self.record_app:
                 print_plugin_warning()
-                print 'ERROR:  Recording %s failed.' % String(rec_prog.title)
+                _debug_('ERROR:  Recording %s failed.' % 
String(rec_prog.title), 0)
                 self.removeScheduledRecording(rec_prog)
                 return
 
-            self.vg = self.fc.getVideoGroup(rec_prog.channel_id, False)
+            self.vg = self.fc.getVideoGroup(rec_prog.channel_id, FALSE)
             suffix=self.vg.vdev.split('/')[-1]
             self.tv_lock_file = config.FREEVO_CACHEDIR + '/record.'+suffix
             self.record_app.Record(rec_prog)
@@ -586,34 +601,34 @@
         oldprio = int(me.priority)
         newprio = oldprio + mod
     
-        _debug_('ap: mod=%s\n' % mod)
+        _debug_('ap: mod=%s' % mod)
        
         sr = self.getScheduledRecordings()
         favs = sr.getFavorites().values()
     
-        sys.stderr.write('adjusting prio of '+favname+'\n')
+        _debug_('adjusting prio of '+favname)
         for fav in favs:
             fav.priority = int(fav.priority)
     
             if fav.name == me.name:
                 _debug_('MATCH')
                 fav.priority = newprio
-                _debug_('moved prio of %s: %s => %s\n' % (fav.name, oldprio, 
newprio))
+                _debug_('moved prio of %s: %s => %s' % (fav.name, oldprio, 
newprio))
                 continue
             if mod < 0:
                 if fav.priority < newprio or fav.priority > oldprio:
-                    _debug_('fp: %s, old: %s, new: %s\n' % (fav.priority, 
oldprio, newprio))
-                    _debug_('skipping: %s\n' % fav.name)
+                    _debug_('fp: %s, old: %s, new: %s' % (fav.priority, 
oldprio, newprio))
+                    _debug_('skipping: %s' % fav.name)
                     continue
                 fav.priority = fav.priority + 1
-                _debug_('moved prio of %s: %s => %s\n' % (fav.name, 
fav.priority-1, fav.priority))
+                _debug_('moved prio of %s: %s => %s' % (fav.name, 
fav.priority-1, fav.priority))
                 
             if mod > 0:
                 if fav.priority > newprio or fav.priority < oldprio:
-                    _debug_('skipping: %s\n' % fav.name)
+                    _debug_('skipping: %s' % fav.name)
                     continue
                 fav.priority = fav.priority - 1
-                _debug_('moved prio of %s: %s => %s\n' % (fav.name, 
fav.priority+1, fav.priority))
+                _debug_('moved prio of %s: %s => %s' % (fav.name, 
fav.priority+1, fav.priority))
     
         sr.setFavoritesList(favs)
         self.saveScheduledRecordings(sr)
@@ -736,26 +751,54 @@
     #################################################################
 
     def xmlrpc_isPlayerRunning(self):
-        status = self.isPlayerRunning()
-        message = status and 'player is running' or 'player is not running'
+        (status, message) = (FALSE, 'isPlayerRunning failed')
+        try:
+            self.lock.acquire()
+            status = self.isPlayerRunning()
+            message = status and 'player is running' or 'player is not running'
+        finally:
+            self.lock.release()
+        return (status, message)
+
+    def xmlrpc_isRecording(self):
+        (status, message) = (FALSE, 'isRecording failed')
+        try:
+            status = self.isRecording()
+            message = status and 'is recording' or 'is not recording'
+        finally:
+            self.lock.release()
         return (status, message)
 
     def xmlrpc_findNextProgram(self):
-        response = self.findNextProgram()
-        status = response != None
-        return (status, jellyToXML(response))
+        (status, message) = (FALSE, 'findNextProgram failed')
+        try:
+            self.lock.acquire()
+            response = self.findNextProgram()
+            status = response != None
+            return (status, jellyToXML(response))
+        finally:
+            self.lock.release()
+        return (status, message)
 
     def xmlrpc_getScheduledRecordings(self):
-        return (TRUE, jellyToXML(self.getScheduledRecordings()))
+        (status, message) = (FALSE, 'isPlayerRunning failed')
+        try:
+            self.lock.acquire()
+            return (TRUE, jellyToXML(self.getScheduledRecordings()))
+        finally:
+            self.lock.release()
+        return (status, message)
 
 
     def xmlrpc_saveScheduledRecordings(self, scheduledRecordings=None):
-        status = self.saveScheduledRecordings(scheduledRecordings)
-
-        if status:
-            return (status, 'saveScheduledRecordings::success')
-        else:
-            return (status, 'saveScheduledRecordings::failure')
+        (status, message) = (FALSE, 'saveScheduledRecordings failed')
+        try:
+            self.lock.acquire()
+            status = self.saveScheduledRecordings(scheduledRecordings)
+            message = status and 'saveScheduledRecordings::success' or 
'saveScheduledRecordings::failure'
+        finally:
+            self.lock.release()
+        return (status, message)
 
 
     def xmlrpc_scheduleRecording(self, prog=None):
@@ -900,7 +943,7 @@
         fxd = FxdImdb()
 
         (filebase, fileext) = os.path.splitext(rec_prog.filename)
-        fxd.setFxdFile(filebase, overwrite = True)
+        fxd.setFxdFile(filebase, overwrite=TRUE)
 
         video = makeVideo('file', 'f1', os.path.basename(rec_prog.filename))
         fxd.setVideo(video)

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to