← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~meths/openlp/trivialfixes into lp:openlp

 

Jon Tibble has proposed merging lp:~meths/openlp/trivialfixes into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/45939

Make ooo stuff more verbose which will hopefully aid debugging and may even let other devs take some of the mounting number of bugs off JC's shoulders.

Fix BibleServer downloads (Bug 701651)
-- 
https://code.launchpad.net/~meths/openlp/trivialfixes/+merge/45939
Your team OpenLP Core is requested to review the proposed merge of lp:~meths/openlp/trivialfixes into lp:openlp.
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py	2011-01-10 01:46:47 +0000
+++ openlp/core/utils/__init__.py	2011-01-11 23:51:58 +0000
@@ -282,13 +282,16 @@
     else:
         return os.path.split(path)
 
-def get_web_page(url, update_openlp=False):
+def get_web_page(url, header=None, update_openlp=False):
     """
     Attempts to download the webpage at url and returns that page or None.
 
     ``url``
         The URL to be downloaded.
 
+    ``header``
+        An optional HTTP header to pass in the request to the web server.
+
     ``update_openlp``
         Tells OpenLP to update itself if the page is successfully downloaded.
         Defaults to False.
@@ -298,10 +301,13 @@
     # http://docs.python.org/library/urllib2.html
     if not url:
         return None
+    req = urllib2.Request(url)
+    if header:
+        req.add_header(header[0], header[1])
     page = None
     log.debug(u'Downloading URL = %s' % url)
     try:
-        page = urllib2.urlopen(url)
+        page = urllib2.urlopen(req)
         log.debug(u'Downloaded URL = %s' % page.geturl())
     except urllib2.URLError:
         log.exception(u'The web page could not be downloaded')

=== modified file 'openlp/plugins/bibles/lib/http.py'
--- openlp/plugins/bibles/lib/http.py	2011-01-10 17:19:25 +0000
+++ openlp/plugins/bibles/lib/http.py	2011-01-11 23:51:58 +0000
@@ -264,7 +264,8 @@
         log.debug(u'get_bible_chapter %s,%s,%s', version, bookname, chapter)
         chapter_url = u'http://m.bibleserver.com/text/%s/%s%s' % \
             (version, bookname, chapter)
-        soup = get_soup_for_bible_ref(chapter_url)
+        header = (u'Accept-Language', u'en')
+        soup = get_soup_for_bible_ref(chapter_url, header)
         if not soup:
             return None
         Receiver.send_message(u'openlp_process_events')
@@ -496,19 +497,22 @@
         """
         return HTTPBooks.get_verse_count(book, chapter)
 
-def get_soup_for_bible_ref(reference_url, cleaner=None):
+def get_soup_for_bible_ref(reference_url, header=None, cleaner=None):
     """
     Gets a webpage and returns a parsed and optionally cleaned soup or None.
 
     ``reference_url``
         The URL to obtain the soup from.
 
+    ``header``
+        An optional HTTP header to pass to the bible web server.
+
     ``cleaner``
         An optional regex to use during webpage parsing.
     """
     if not reference_url:
         return None
-    page = get_web_page(reference_url, True)
+    page = get_web_page(reference_url, header, True)
     if not page:
         send_error_message(u'download')
         return None

=== modified file 'openlp/plugins/presentations/lib/impresscontroller.py'
--- openlp/plugins/presentations/lib/impresscontroller.py	2010-12-29 09:14:13 +0000
+++ openlp/plugins/presentations/lib/impresscontroller.py	2011-01-11 23:51:58 +0000
@@ -169,7 +169,7 @@
         try:
             return Dispatch(u'com.sun.star.ServiceManager')
         except pywintypes.com_error:
-            log.warn(u'Failed to get COM service manager. '
+            log.exception(u'Failed to get COM service manager. '
                 u'Impress Controller has been disabled')
             return None
 
@@ -257,7 +257,6 @@
         except:
             log.exception(u'Failed to load presentation %s' % url)
             return False
-
         self.presentation = self.document.getPresentation()
         self.presentation.Display = \
             self.controller.plugin.renderManager.screens.current_display + 1
@@ -327,8 +326,7 @@
                     self.presentation = None
                     self.document.dispose()
                 except:
-                    #We tried!
-                    pass
+                    log.exception("Closing presentation failed")
             self.document = None
         self.controller.remove_doc(self)
 
@@ -339,13 +337,14 @@
         log.debug(u'is loaded OpenOffice')
         #print "is_loaded "
         if self.presentation is None or self.document is None:
-            #print "no present or document"
+            log.debug("is_loaded: no presentation or document")
             return False
         try:
             if self.document.getPresentation() is None:
-                #print "no getPresentation"
+                log.debug("getPresentation failed to find a presentation")
                 return False
         except:
+            log.exception("getPresentation failed to find a presentation")
             return False
         return True
 

=== modified file 'openlp/plugins/songs/lib/oooimport.py'
--- openlp/plugins/songs/lib/oooimport.py	2010-12-26 11:04:47 +0000
+++ openlp/plugins/songs/lib/oooimport.py	2011-01-11 23:51:58 +0000
@@ -116,7 +116,7 @@
                             + u'socket,host=localhost,port=2002;' \
                             + u'urp;StarOffice.ComponentContext')
                 except:
-                    pass
+                    log.exception("Failed to resolve uno connection")
                 self.start_ooo_process()
                 loop += 1
             manager = ctx.ServiceManager
@@ -143,7 +143,7 @@
                 process.waitForStarted()
             self.process_started = True
         except:
-            pass
+            log.exception("start_ooo_process failed")
 
     def open_ooo_file(self, filepath):
         """
@@ -167,7 +167,7 @@
                 self.import_wizard.incrementProgressBar(
                     u'Processing file ' + filepath, 0)
         except:
-            pass
+            log.exception("open_ooo_file failed")
         return
 
     def close_ooo_file(self):
@@ -232,4 +232,4 @@
             text += paratext + u'\n'
         songs = SongImport.process_songs_text(self.manager, text)
         for song in songs:
-            song.finish()
\ No newline at end of file
+            song.finish()