Author: duncan
Date: Sat Dec 23 19:14:04 2006
New Revision: 8795

Modified:
   branches/rel-1/freevo/src/helpers/recordserver.py
   branches/rel-1/freevo/src/tv/epg_types.py
   branches/rel-1/freevo/src/tv/plugins/generic_record.py
   branches/rel-1/freevo/src/tv/plugins/vbi2srt_record.py
   branches/rel-1/freevo/src/tv/record_types.py

Log:
Changed mostly messages
Added the PDC start time to a program
Fixed record plugins so they do not print a kill message when correctly exited


Modified: branches/rel-1/freevo/src/helpers/recordserver.py
==============================================================================
--- branches/rel-1/freevo/src/helpers/recordserver.py   (original)
+++ branches/rel-1/freevo/src/helpers/recordserver.py   Sat Dec 23 19:14:04 2006
@@ -136,6 +136,7 @@
         proglist = list(progs)
         proglist.sort(self.progsTimeCompare)
         now = time.time()
+        timenow = time.localtime(now)
         for progitem in proglist:
             prog = progs[progitem]
             _debug_('%s' % (prog), 2)
@@ -146,11 +147,11 @@
                 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), 2)
+            endtime = time.localtime(prog.stop+config.TV_RECORD_PADDING_POST)
+            if now > prog.stop + config.TV_RECORD_PADDING_POST:
+                _debug_('%s: prog.stop=%s, now=%s' % (prog.title, endtime, 
timenow), 2)
                 continue
-            _debug_('%s: prog.stop=%s' % (prog.title, 
time.localtime(prog.stop)))
+            _debug_('%s: endtime=%s' % (prog.title, endtime))
 
             if not recording:
                 next_program = prog
@@ -259,15 +260,15 @@
         if not prog:
             return (FALSE, 'no prog')
     
-        if prog.stop < time.time():
+        now = time.time()
+        if now > prog.stop:
             return (FALSE, 'cannot record it if it is over')
             
         self.updateGuide()
     
         for chan in guide.chan_list:
             if prog.channel_id == chan.id:
-                _debug_('scheduleRecording: prog.channel_id="%s" chan.id="%s" 
chan.tunerid="%s"' %
-                    (prog.channel_id, chan.id, chan.tunerid))
+                _debug_('scheduleRecording: "%s"' % (prog))
                 prog.tunerid = chan.tunerid
     
         scheduledRecordings = self.getScheduledRecordings()
@@ -297,7 +298,7 @@
         try:
             recording = prog.isRecording
         except Exception, e:
-            print 'removeScheduledRecording:', e
+            print 'prog.isRecording:', e
             recording = FALSE
 
         scheduledRecordings = self.getScheduledRecordings()
@@ -305,9 +306,9 @@
         self.saveScheduledRecordings(scheduledRecordings)
         now = time.time()
 
-        # if prog.start <= now and prog.stop >= now and recording:
+        # if now >= prog.start and now <= prog.stop and recording:
         if recording:
-            #print 'stopping current recording'
+            print 'stopping current recording %s' % (prog)
             rec_plugin = plugin.getbyname('RECORD')
             if rec_plugin:
                 rec_plugin.Stop()
@@ -371,7 +372,7 @@
 
         for ch in guide.chan_list:
             for prog in ch.programs:
-                if prog.stop < now:
+                if now >= prog.stop:
                     continue
                 if not find or regex.match(prog.title) or 
regex.match(prog.desc) \
                    or regex.match(prog.sub_title):
@@ -393,14 +394,11 @@
 
         if matches:
             return (TRUE, matches)
-        else:
-            return (FALSE, 'no matches')
+        return (FALSE, 'no matches')
 
 
     def updateGuide(self):
         global guide
-
-        # XXX TODO: only do this if the guide has changed?
         guide = tv.epg_xmltv.get_guide()
 
         
@@ -432,15 +430,14 @@
             except:
                 recording = FALSE
 
-            if (prog.start - config.TV_RECORD_PADDING_PRE) <= now \
-                   and (prog.stop + config.TV_RECORD_PADDING_POST) >= now \
-                   and not recording:
+            if not recording \
+                and now >= (prog.start - config.TV_RECORD_PADDING_PRE) \
+                and now < (prog.stop + config.TV_RECORD_PADDING_POST):
                 # 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
-                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)
+                duration = int((prog.stop + config.TV_RECORD_PADDING_POST) - 
now)
                 if duration < 10:
                     return 
 
@@ -453,10 +450,10 @@
                         # has a higher priority.
 
 
-                        if self.isProgAFavorite(prog)[0] and \
-                           not self.isProgAFavorite(currently_recording)[0] 
and \
-                           prog.stop + config.TV_RECORD_PADDING_POST > now:
-                            _debug_('ignore %s' % prog)
+                        if self.isProgAFavorite(prog)[0] \
+                            and not 
self.isProgAFavorite(currently_recording)[0] \
+                            and now < (prog.stop + 
config.TV_RECORD_PADDING_POST):
+                            _debug_('Ignoring %s' % prog)
                             continue
                         sr.removeProgram(currently_recording, 
                                          tv_util.getKey(currently_recording))
@@ -498,7 +495,7 @@
 
         for prog in progs.values():
             # If the program is over remove the entry.
-            if ( prog.stop + config.TV_RECORD_PADDING_POST) < now:
+            if now > (prog.stop + config.TV_RECORD_PADDING_POST):
                 _debug_('found a program to clean: %s' % prog)
                 cleaned = TRUE
                 del progs[tv_util.getKey(prog)]
@@ -1069,7 +1066,6 @@
 
 
     def handleEvents(self):
-        #print 'RECORDSERVER HANDLING EVENT'
         event = rc_object.get_event()
 
         if event:
@@ -1129,7 +1125,7 @@
                 print 'recorderver: After wait()'
 
             elif event == RECORD_START:
-                #print 'Handling event RECORD_START'
+                print 'received event RECORD_START'
                 prog = event.arg
                 open(self.tv_lock_file, 'w').close()
                 self.create_fxd(prog)
@@ -1137,7 +1133,7 @@
                     util.popen3.Popen3(config.VCR_PRE_REC)
 
             elif event == RECORD_STOP:
-                #print 'Handling event RECORD_STOP'
+                print 'received event RECORD_STOP'
                 os.remove(self.tv_lock_file)
                 prog = event.arg
                 try:

Modified: branches/rel-1/freevo/src/tv/epg_types.py
==============================================================================
--- branches/rel-1/freevo/src/tv/epg_types.py   (original)
+++ branches/rel-1/freevo/src/tv/epg_types.py   Sat Dec 23 19:14:04 2006
@@ -84,16 +84,18 @@
 
 
     def __str__(self):
+        st = time.localtime(self.pdc_start) # PDC start time
         bt = time.localtime(self.start)   # Beginning time tuple
         et = time.localtime(self.stop)    # End time tuple
         begins = time.strftime('%a %Y-%m-%d %H:%M', bt)
+        starts = time.strftime('%H:%M', st)
         ends = time.strftime('%H:%M', et)
         try:
             channel_id = String(self.channel_id)
             title = String(self.title)
-            s = '%s->%s  %3s %s' % (begins, ends, channel_id, title)
+            s = '%s->%s (%s)  %3s %s' % (begins, ends, starts, channel_id, 
title)
         except UnicodeEncodeError: #just in case
-            s = '%s->%s. %3s %s' % (begins, ends, self.channel_id, self.title)
+            s = '%s->%s [%s] %3s %s' % (begins, ends, starts, self.channel_id, 
self.title)
         return s
 
 

Modified: branches/rel-1/freevo/src/tv/plugins/generic_record.py
==============================================================================
--- branches/rel-1/freevo/src/tv/plugins/generic_record.py      (original)
+++ branches/rel-1/freevo/src/tv/plugins/generic_record.py      Sat Dec 23 
19:14:04 2006
@@ -161,17 +161,15 @@
                             print 'autokill timeout, stopping recording'
                         self.mode = 'stop'
                         
-                if DEBUG: print('Record_Thread::run: past wait()!!')
-
-                rc.post_event(Event(OS_EVENT_KILL, (self.app.child.pid, 15)))
-                self.app.kill()
-
-                self.mode = 'idle'
+                if self.app.isAlive():
+                    if DEBUG: print('Record_Thread::run: past wait()!!')
+                    rc.post_event(Event(OS_EVENT_KILL, (self.app.child.pid, 
15)))
+                    self.app.kill()
 
                 rc.post_event(Event('RECORD_STOP', arg=self.prog))
                 if DEBUG: print('Record_Thread::run: finished recording')
-                
+
+                self.mode = 'idle'
             else:
                 self.mode = 'idle'
             time.sleep(0.5)
-

Modified: branches/rel-1/freevo/src/tv/plugins/vbi2srt_record.py
==============================================================================
--- branches/rel-1/freevo/src/tv/plugins/vbi2srt_record.py      (original)
+++ branches/rel-1/freevo/src/tv/plugins/vbi2srt_record.py      Sat Dec 23 
19:14:04 2006
@@ -246,17 +246,16 @@
                             print 'autokill timeout, stopping recording'
                         self.mode = 'stop'
                         
-                if DEBUG: print('Record_Thread::run: past wait()!!')
-
-                rc.post_event(Event(OS_EVENT_KILL, (self.app.child.pid, 15)))
-                self.app.kill()
-
-                self.mode = 'idle'
+                if self.app.isAlive():
+                    # might not want to do this is PDC is valid, programme may 
be delayed
+                    if DEBUG: print('Record_Thread::run: past wait!!')
+                    rc.post_event(Event(OS_EVENT_KILL, (self.app.child.pid, 
15)))
+                    self.app.kill()
 
                 rc.post_event(Event('RECORD_STOP', arg=self.prog))
                 if DEBUG: print('Record_Thread::run: finished recording')
-                
+
+                self.mode = 'idle'
             else:
                 self.mode = 'idle'
             time.sleep(0.5)
-

Modified: branches/rel-1/freevo/src/tv/record_types.py
==============================================================================
--- branches/rel-1/freevo/src/tv/record_types.py        (original)
+++ branches/rel-1/freevo/src/tv/record_types.py        Sat Dec 23 19:14:04 2006
@@ -52,7 +52,7 @@
             pass
 
         print 'config.LOCALE=%s' % config.LOCALE
-        print 'type(prog)=%s prog=%s' % (type(prog), prog)
+        print 'prog=%s' % (prog)
 
         if config.DEBUG:
             print 'addProgram: key is "%s"' % String(key)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to