← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tomasgroth/openlp/24bugfix-backport3 into lp:openlp/2.4

 

Tomas Groth has proposed merging lp:~tomasgroth/openlp/24bugfix-backport3 into lp:openlp/2.4.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1585489 in OpenLP: "Traceback during songshowplus import"
  https://bugs.launchpad.net/openlp/+bug/1585489
  Bug #1590657 in OpenLP: "MediaShout import causes traceback"
  https://bugs.launchpad.net/openlp/+bug/1590657

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/24bugfix-backport3/+merge/297694

Fix traceback in VideoPsalm importers traceback handler.
Skip PresentationManager files we do not support.
Fix MediaShout import issue when an expected table is missing. Fixes bug 1590657.
Fix traceback during songshowplus import. Fixes bug 1585489.
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/24bugfix-backport3 into lp:openlp/2.4.
=== modified file 'openlp/plugins/songs/lib/importers/mediashout.py'
--- openlp/plugins/songs/lib/importers/mediashout.py	2015-12-31 22:46:06 +0000
+++ openlp/plugins/songs/lib/importers/mediashout.py	2016-06-16 21:15:45 +0000
@@ -59,6 +59,7 @@
         songs = cursor.fetchall()
         self.import_wizard.progress_bar.setMaximum(len(songs))
         for song in songs:
+            topics = []
             if self.stop_import_flag:
                 break
             cursor.execute('SELECT Type, Number, Text FROM Verses WHERE Record = %s ORDER BY Type, Number'
@@ -66,9 +67,10 @@
             verses = cursor.fetchall()
             cursor.execute('SELECT Type, Number, POrder FROM PlayOrder WHERE Record = %s ORDER BY POrder' % song.Record)
             verse_order = cursor.fetchall()
-            cursor.execute('SELECT Name FROM Themes INNER JOIN SongThemes ON SongThemes.ThemeId = Themes.ThemeId '
-                           'WHERE SongThemes.Record = %s' % song.Record)
-            topics = cursor.fetchall()
+            if cursor.tables(table='TableName', tableType='TABLE').fetchone():
+                cursor.execute('SELECT Name FROM Themes INNER JOIN SongThemes ON SongThemes.ThemeId = Themes.ThemeId '
+                               'WHERE SongThemes.Record = %s' % song.Record)
+                topics = cursor.fetchall()
             cursor.execute('SELECT Name FROM Groups INNER JOIN SongGroups ON SongGroups.GroupId = Groups.GroupId '
                            'WHERE SongGroups.Record = %s' % song.Record)
             topics += cursor.fetchall()

=== modified file 'openlp/plugins/songs/lib/importers/presentationmanager.py'
--- openlp/plugins/songs/lib/importers/presentationmanager.py	2015-12-31 22:46:06 +0000
+++ openlp/plugins/songs/lib/importers/presentationmanager.py	2016-06-16 21:15:45 +0000
@@ -54,7 +54,13 @@
                 # Open file with detected encoding and remove encoding declaration
                 text = open(file_path, mode='r', encoding=encoding).read()
                 text = re.sub('.+\?>\n', '', text)
-                tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
+                try:
+                    tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
+                except ValueError:
+                    self.log_error(file_path,
+                                   translate('SongsPlugin.PresentationManagerImport',
+                                             'File is not in XML-format, which is the only format supported.'))
+                    continue
             root = objectify.fromstring(etree.tostring(tree))
             self.process_song(root)
 

=== modified file 'openlp/plugins/songs/lib/importers/songshowplus.py'
--- openlp/plugins/songs/lib/importers/songshowplus.py	2015-12-31 22:46:06 +0000
+++ openlp/plugins/songs/lib/importers/songshowplus.py	2016-06-16 21:15:45 +0000
@@ -116,7 +116,13 @@
                     null, verse_name_length, = struct.unpack("BB", song_data.read(2))
                     verse_name = self.decode(song_data.read(verse_name_length))
                 length_descriptor_size, = struct.unpack("B", song_data.read(1))
-                log.debug(length_descriptor_size)
+                log.debug('length_descriptor_size: %d' % length_descriptor_size)
+                # In the case of song_numbers the number is in the data from the
+                # current position to the next block starts
+                if block_key == SONG_NUMBER:
+                    sn_bytes = song_data.read(length_descriptor_size - 1)
+                    self.song_number = int.from_bytes(sn_bytes, byteorder='little')
+                    continue
                 # Detect if/how long the length descriptor is
                 if length_descriptor_size == 12 or length_descriptor_size == 20:
                     length_descriptor, = struct.unpack("I", song_data.read(4))

=== modified file 'openlp/plugins/songs/lib/importers/videopsalm.py'
--- openlp/plugins/songs/lib/importers/videopsalm.py	2016-01-08 19:52:24 +0000
+++ openlp/plugins/songs/lib/importers/videopsalm.py	2016-06-16 21:15:45 +0000
@@ -117,6 +117,6 @@
                 if not self.finish():
                     self.log_error('Could not import %s' % self.title)
         except Exception as e:
-            self.log_error(translate('SongsPlugin.VideoPsalmImport', 'File %s' % file.name),
+            self.log_error(self.import_source,
                            translate('SongsPlugin.VideoPsalmImport', 'Error: %s') % e)
         song_file.close()

=== modified file 'tests/functional/openlp_plugins/songs/test_songshowplusimport.py'
--- tests/functional/openlp_plugins/songs/test_songshowplusimport.py	2015-12-31 22:46:06 +0000
+++ tests/functional/openlp_plugins/songs/test_songshowplusimport.py	2016-06-16 21:15:45 +0000
@@ -52,6 +52,8 @@
                          self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json')))
         self.file_import([os.path.join(TEST_PATH, 'a mighty fortress is our god.sbsong')],
                          self.load_external_result_data(os.path.join(TEST_PATH, 'a mighty fortress is our god.json')))
+        self.file_import([os.path.join(TEST_PATH, 'cleanse-me.sbsong')],
+                         self.load_external_result_data(os.path.join(TEST_PATH, 'cleanse-me.json')))
 
 
 class TestSongShowPlusImport(TestCase):

=== added file 'tests/resources/songshowplussongs/cleanse-me.json'
--- tests/resources/songshowplussongs/cleanse-me.json	1970-01-01 00:00:00 +0000
+++ tests/resources/songshowplussongs/cleanse-me.json	2016-06-16 21:15:45 +0000
@@ -0,0 +1,38 @@
+{
+    "authors": [
+        "J. Edwin Orr"
+    ],
+    "ccli_number": 56307,
+    "comments": "",
+    "copyright": "Public Domain ",
+    "song_book_name": "",
+    "song_number": 438,
+    "title": "Cleanse Me [438]",
+    "topics": [
+        "Cleansing",
+        "Communion",
+        "Consecration",
+        "Holiness",
+        "Holy Spirit",
+        "Revival"
+    ],
+    "verse_order_list": [],
+    "verses": [
+        [
+            "Search me, O God,\r\nAnd know my heart today;\r\nTry me, O Savior,\r\nKnow my thoughts, I pray.\r\nSee if there be\r\nSome wicked way in me;\r\nCleanse me from every sin\r\nAnd set me free.",
+            "v1"
+        ],
+        [
+            "I praise Thee, Lord,\r\nFor cleansing me from sin;\r\nFulfill Thy Word,\r\nAnd make me pure within.\r\nFill me with fire\r\nWhere once I burned with shame;\r\nGrant my desire\r\nTo magnify Thy name.",
+            "v2"
+        ],
+        [
+            "Lord, take my life,\r\nAnd make it wholly Thine;\r\nFill my poor heart\r\nWith Thy great love divine.\r\nTake all my will,\r\nMy passion, self and pride;\r\nI now surrender, Lord\r\nIn me abide.",
+            "v3"
+        ],
+        [
+            "O Holy Ghost,\r\nRevival comes from Thee;\r\nSend a revival,\r\nStart the work in me.\r\nThy Word declares\r\nThou wilt supply our need;\r\nFor blessings now,\r\nO Lord, I humbly plead.",
+            "v4"
+        ]
+    ]
+}

=== added file 'tests/resources/songshowplussongs/cleanse-me.sbsong'
Binary files tests/resources/songshowplussongs/cleanse-me.sbsong	1970-01-01 00:00:00 +0000 and tests/resources/songshowplussongs/cleanse-me.sbsong	2016-06-16 21:15:45 +0000 differ

References