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

Proposed by Tomas Groth
Status: Merged
Merged at revision: 2638
Proposed branch: lp:~tomasgroth/openlp/24bugfix-backport3
Merge into: lp:openlp/2.4
Diff against target: 134 lines (+60/-6)
6 files modified
openlp/plugins/songs/lib/importers/mediashout.py (+5/-3)
openlp/plugins/songs/lib/importers/presentationmanager.py (+7/-1)
openlp/plugins/songs/lib/importers/songshowplus.py (+7/-1)
openlp/plugins/songs/lib/importers/videopsalm.py (+1/-1)
tests/functional/openlp_plugins/songs/test_songshowplusimport.py (+2/-0)
tests/resources/songshowplussongs/cleanse-me.json (+38/-0)
To merge this branch: bzr merge lp:~tomasgroth/openlp/24bugfix-backport3
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+297694@code.launchpad.net

This proposal supersedes a proposal from 2016-06-16.

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote : Posted in a previous version of this proposal
Revision history for this message
Tomas Groth (tomasgroth) wrote :

Resubmitted to right branch...

Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/songs/lib/importers/mediashout.py'
2--- openlp/plugins/songs/lib/importers/mediashout.py 2015-12-31 22:46:06 +0000
3+++ openlp/plugins/songs/lib/importers/mediashout.py 2016-06-16 21:15:45 +0000
4@@ -59,6 +59,7 @@
5 songs = cursor.fetchall()
6 self.import_wizard.progress_bar.setMaximum(len(songs))
7 for song in songs:
8+ topics = []
9 if self.stop_import_flag:
10 break
11 cursor.execute('SELECT Type, Number, Text FROM Verses WHERE Record = %s ORDER BY Type, Number'
12@@ -66,9 +67,10 @@
13 verses = cursor.fetchall()
14 cursor.execute('SELECT Type, Number, POrder FROM PlayOrder WHERE Record = %s ORDER BY POrder' % song.Record)
15 verse_order = cursor.fetchall()
16- cursor.execute('SELECT Name FROM Themes INNER JOIN SongThemes ON SongThemes.ThemeId = Themes.ThemeId '
17- 'WHERE SongThemes.Record = %s' % song.Record)
18- topics = cursor.fetchall()
19+ if cursor.tables(table='TableName', tableType='TABLE').fetchone():
20+ cursor.execute('SELECT Name FROM Themes INNER JOIN SongThemes ON SongThemes.ThemeId = Themes.ThemeId '
21+ 'WHERE SongThemes.Record = %s' % song.Record)
22+ topics = cursor.fetchall()
23 cursor.execute('SELECT Name FROM Groups INNER JOIN SongGroups ON SongGroups.GroupId = Groups.GroupId '
24 'WHERE SongGroups.Record = %s' % song.Record)
25 topics += cursor.fetchall()
26
27=== modified file 'openlp/plugins/songs/lib/importers/presentationmanager.py'
28--- openlp/plugins/songs/lib/importers/presentationmanager.py 2015-12-31 22:46:06 +0000
29+++ openlp/plugins/songs/lib/importers/presentationmanager.py 2016-06-16 21:15:45 +0000
30@@ -54,7 +54,13 @@
31 # Open file with detected encoding and remove encoding declaration
32 text = open(file_path, mode='r', encoding=encoding).read()
33 text = re.sub('.+\?>\n', '', text)
34- tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
35+ try:
36+ tree = etree.fromstring(text, parser=etree.XMLParser(recover=True))
37+ except ValueError:
38+ self.log_error(file_path,
39+ translate('SongsPlugin.PresentationManagerImport',
40+ 'File is not in XML-format, which is the only format supported.'))
41+ continue
42 root = objectify.fromstring(etree.tostring(tree))
43 self.process_song(root)
44
45
46=== modified file 'openlp/plugins/songs/lib/importers/songshowplus.py'
47--- openlp/plugins/songs/lib/importers/songshowplus.py 2015-12-31 22:46:06 +0000
48+++ openlp/plugins/songs/lib/importers/songshowplus.py 2016-06-16 21:15:45 +0000
49@@ -116,7 +116,13 @@
50 null, verse_name_length, = struct.unpack("BB", song_data.read(2))
51 verse_name = self.decode(song_data.read(verse_name_length))
52 length_descriptor_size, = struct.unpack("B", song_data.read(1))
53- log.debug(length_descriptor_size)
54+ log.debug('length_descriptor_size: %d' % length_descriptor_size)
55+ # In the case of song_numbers the number is in the data from the
56+ # current position to the next block starts
57+ if block_key == SONG_NUMBER:
58+ sn_bytes = song_data.read(length_descriptor_size - 1)
59+ self.song_number = int.from_bytes(sn_bytes, byteorder='little')
60+ continue
61 # Detect if/how long the length descriptor is
62 if length_descriptor_size == 12 or length_descriptor_size == 20:
63 length_descriptor, = struct.unpack("I", song_data.read(4))
64
65=== modified file 'openlp/plugins/songs/lib/importers/videopsalm.py'
66--- openlp/plugins/songs/lib/importers/videopsalm.py 2016-01-08 19:52:24 +0000
67+++ openlp/plugins/songs/lib/importers/videopsalm.py 2016-06-16 21:15:45 +0000
68@@ -117,6 +117,6 @@
69 if not self.finish():
70 self.log_error('Could not import %s' % self.title)
71 except Exception as e:
72- self.log_error(translate('SongsPlugin.VideoPsalmImport', 'File %s' % file.name),
73+ self.log_error(self.import_source,
74 translate('SongsPlugin.VideoPsalmImport', 'Error: %s') % e)
75 song_file.close()
76
77=== modified file 'tests/functional/openlp_plugins/songs/test_songshowplusimport.py'
78--- tests/functional/openlp_plugins/songs/test_songshowplusimport.py 2015-12-31 22:46:06 +0000
79+++ tests/functional/openlp_plugins/songs/test_songshowplusimport.py 2016-06-16 21:15:45 +0000
80@@ -52,6 +52,8 @@
81 self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json')))
82 self.file_import([os.path.join(TEST_PATH, 'a mighty fortress is our god.sbsong')],
83 self.load_external_result_data(os.path.join(TEST_PATH, 'a mighty fortress is our god.json')))
84+ self.file_import([os.path.join(TEST_PATH, 'cleanse-me.sbsong')],
85+ self.load_external_result_data(os.path.join(TEST_PATH, 'cleanse-me.json')))
86
87
88 class TestSongShowPlusImport(TestCase):
89
90=== added file 'tests/resources/songshowplussongs/cleanse-me.json'
91--- tests/resources/songshowplussongs/cleanse-me.json 1970-01-01 00:00:00 +0000
92+++ tests/resources/songshowplussongs/cleanse-me.json 2016-06-16 21:15:45 +0000
93@@ -0,0 +1,38 @@
94+{
95+ "authors": [
96+ "J. Edwin Orr"
97+ ],
98+ "ccli_number": 56307,
99+ "comments": "",
100+ "copyright": "Public Domain ",
101+ "song_book_name": "",
102+ "song_number": 438,
103+ "title": "Cleanse Me [438]",
104+ "topics": [
105+ "Cleansing",
106+ "Communion",
107+ "Consecration",
108+ "Holiness",
109+ "Holy Spirit",
110+ "Revival"
111+ ],
112+ "verse_order_list": [],
113+ "verses": [
114+ [
115+ "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.",
116+ "v1"
117+ ],
118+ [
119+ "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.",
120+ "v2"
121+ ],
122+ [
123+ "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.",
124+ "v3"
125+ ],
126+ [
127+ "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.",
128+ "v4"
129+ ]
130+ ]
131+}
132
133=== added file 'tests/resources/songshowplussongs/cleanse-me.sbsong'
134Binary 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

Subscribers

People subscribed via source and target branches

to all changes: