Author: duncan
Date: Mon Mar 17 08:12:49 2008
New Revision: 10542

Log:
[ 1916020 ] Webserver crash when searching
Fix applied, also fixed non-ascii characters in the search and genre search


Modified:
   branches/rel-1/freevo/src/helpers/recordserver.py
   branches/rel-1/freevo/src/tv/epg_xmltv.py
   branches/rel-1/freevo/src/tv/programitem.py
   branches/rel-1/freevo/src/tv/record_client.py
   branches/rel-1/freevo/src/www/htdocs/genre.rpy

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   Mon Mar 17 08:12:49 2008
@@ -807,7 +807,9 @@
         matches = []
         max_results = 500
 
-        if not find and not movies_only:
+        if find:
+            find = Unicode(find)
+        elif not movies_only:
             _debug_('nothing to find', DINFO)
             return (False, _('nothing to find'))
 
@@ -821,17 +823,14 @@
             for prog in ch.programs:
                 if now >= prog.stop:
                     continue
-                if not find or regex.match(prog.title) or 
regex.match(prog.desc) \
-                   or regex.match(prog.sub_title):
+                if not find or regex.match(prog.title) or 
regex.match(prog.desc) or regex.match(prog.sub_title):
                     if movies_only:
-                        # We can do better here than just look for the MPAA
-                        # rating.  Suggestions are welcome.
+                        # We can do better here than just look for the MPAA 
rating.
+                        # Suggestions are welcome.
                         if 'MPAA' in prog.utf2str().getattr('ratings').keys():
                             matches.append(prog.utf2str())
                             _debug_('PROGRAM MATCH 2: %s' % prog, DINFO)
                     else:
-                        # We should never get here if not find and not
-                        # movies_only.
                         matches.append(prog.utf2str())
                         _debug_('PROGRAM MATCH 3: %s' % prog, DINFO)
                 if len(matches) >= max_results:
@@ -839,9 +838,9 @@
 
         _debug_('Found %d matches.' % len(matches), DINFO)
 
-        if matches:
-            return (True, matches)
-        return (False, _('no programs match'))
+        if len(matches) == 0:
+            return (False, _('no programs match'))
+        return (True, matches)
 
 
     def updateGuide(self):

Modified: branches/rel-1/freevo/src/tv/epg_xmltv.py
==============================================================================
--- branches/rel-1/freevo/src/tv/epg_xmltv.py   (original)
+++ branches/rel-1/freevo/src/tv/epg_xmltv.py   Mon Mar 17 08:12:49 2008
@@ -235,14 +235,14 @@
             continue
         try:
             channel_id = p['channel']
-            date = 'date' in p and Unicode(p['date']) or None
-            start = None
-            pdc_start = None
-            stop = None
+            date = 'date' in p and Unicode(p['date']) or ''
+            start = ''
+            pdc_start = ''
+            stop = ''
             title = Unicode(p['title'][0][0])
-            desc = 'desc' in p and Unicode(util.format_text(p['desc'][0][0])) 
or None
-            sub_title = 'sub-title' in p and Unicode(p['sub-title'][0][0]) or 
None
-            categories = 'category' in p and [ cat[0] for cat in p['category'] 
] or None
+            desc = 'desc' in p and Unicode(util.format_text(p['desc'][0][0])) 
or ''
+            sub_title = 'sub-title' in p and Unicode(p['sub-title'][0][0]) or 
''
+            categories = 'category' in p and [ cat[0] for cat in p['category'] 
] or ''
             advisories = []
             ratings = {}
 

Modified: branches/rel-1/freevo/src/tv/programitem.py
==============================================================================
--- branches/rel-1/freevo/src/tv/programitem.py (original)
+++ branches/rel-1/freevo/src/tv/programitem.py Mon Mar 17 08:12:49 2008
@@ -287,7 +287,7 @@
             for prog in matches:
                 items.append(ProgramItem(self.parent, prog, context='search'))
         elif matches == 'no matches':
-                # there have been no matches
+            # there have been no matches
             msgtext = _('No matches found for %s') % self.title
             AlertBox(text=msgtext).show()
             return

Modified: branches/rel-1/freevo/src/tv/record_client.py
==============================================================================
--- branches/rel-1/freevo/src/tv/record_client.py       (original)
+++ branches/rel-1/freevo/src/tv/record_client.py       Mon Mar 17 08:12:49 2008
@@ -261,7 +261,7 @@
         return result
 
 
-    def findMatchesNow(self, title=None, movies_only=None):
+    def findMatchesNow(self, title=None, movies_only=False):
         """ See if a programme is a favourite """
         _debug_('findMatchesNow(title=%r, movies_only=%r)' % (title, 
movies_only), 1)
         inprogress = self._recordserver_rpc('findMatches', title, movies_only)

Modified: branches/rel-1/freevo/src/www/htdocs/genre.rpy
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/genre.rpy      (original)
+++ branches/rel-1/freevo/src/www/htdocs/genre.rpy      Mon Mar 17 08:12:49 2008
@@ -63,6 +63,13 @@
         fv = HTMLResource()
         form = request.args
 
+        server_available = self.recordclient.pingNow()
+        if not server_available:
+            fv.printHeader(_('TV Genre for %s') % time.strftime('%a %b %d', 
time.localtime(mfrguidestart)), \
+                config.WWW_STYLESHEET, config.WWW_JAVASCRIPT)
+            fv.printMessagesFinish(['<b>'+_('ERROR')+'</b>: 
'+self.recordclient.recordserverdown])
+            return String(fv.res)
+
         mfrguidestart = time.time()
         mfrguideinput = fv.formValue(form, 'stime')
         if mfrguideinput:
@@ -85,14 +92,9 @@
 
         guide = tv.epg_xmltv.get_guide()
         (status, schedule) = self.recordclient.getScheduledRecordingsNow()
-        if status:
-            program_list = schedule.getProgramList()
-
-        fv.printHeader(_('TV Genre for %s') % time.strftime('%a %b %d', 
time.localtime(mfrguidestart)), \
-            config.WWW_STYLESHEET, config.WWW_JAVASCRIPT)
-
-        if schedule is None:
-            fv.printMessages(['<b>'+_('ERROR')+'</b>: '+_('Recording server is 
not available')])
+        if not status:
+            fv.printMessagesFinish(['<b>'+_('ERROR')+'</b>: '+_('No program 
schedule')])
+            return String(fv.res)
 
         allcategories = []
         for chan in guide.chan_list:
@@ -131,7 +133,7 @@
             fv.printSearchForm()
             fv.printLinks()
             fv.printFooter()
-            return String( fv.res )
+            return String(fv.res)
 
         fv.tableOpen('border="0" cellpadding="4" cellspacing="1" width="100%"')
         fv.tableRowOpen('class="chanrow"')
@@ -156,15 +158,14 @@
 
                     # use counter to see if we have data
                     gotdata += 1
-                    if got_schedule:
-                        (result, reason) = 
self.recordclient.isProgScheduledNow(prog, schedule)
-                        if result:
-                            status = 'scheduled'
-                            really_now = time.time()
-                            if prog.start <= really_now and prog.stop >= 
really_now:
-                                # in the future we should REALLY see if it is
-                                # recording instead of just guessing
-                                status = 'recording'
+                    (result, reason) = 
self.recordclient.isProgScheduledNow(prog, schedule)
+                    if result:
+                        status = 'scheduled'
+                        really_now = time.time()
+                        if prog.start <= really_now and prog.stop >= 
really_now:
+                            # in the future we should REALLY see if it is
+                            # recording instead of just guessing
+                            status = 'recording'
 
                     fv.tableRowOpen('class="chanrow"')
                     fv.tableCell(chan.displayname, 'class="channel"')
@@ -235,7 +236,7 @@
         fv.res += "<iframe id='hidden' style='visibility: hidden; width: 1px; 
height: 1px'></iframe>\n"
         fv.printFooter()
 
-        return String( fv.res )
+        return String(fv.res)
 
 
 resource = GenreResource()

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to