openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #17956
[Merge] lp:~phill-ridout/openlp/1065420 into lp:openlp
phill has proposed merging lp:~phill-ridout/openlp/1065420 into lp:openlp.
Requested reviews:
Jonathan Corwin (j-corwin)
Raoul Snyman (raoul-snyman)
Tim Bentley (trb143)
Related bugs:
Bug #1065420 in OpenLP: ""missing files" dialog opens more then once when more files are missing"
https://bugs.launchpad.net/openlp/+bug/1065420
Bug #1065423 in OpenLP: "Missing image in service causes traceback when opening"
https://bugs.launchpad.net/openlp/+bug/1065423
For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/1065420/+merge/133348
Fixes bug 1065423 "Missing image in service causes traceback when opening"
Fixes bug 1065420 ""missing files" dialog opens more then once when more files are missing"
Removes items with missing files prior to saving (after confirmation from user)
Fixed indentation
Added some methods to serviceitem.py so as not to expose "inner workings of ServiceItem" and modified
get_frame_path method. (Which required a modification to slidecontroller.py & messagelistener.py)
Simplified validate method as per Raouls request.
--
https://code.launchpad.net/~phill-ridout/openlp/1065420/+merge/133348
Your team OpenLP Core is subscribed to branch lp:openlp.
=== modified file 'openlp/core/lib/serviceitem.py'
--- openlp/core/lib/serviceitem.py 2012-10-21 14:07:57 +0000
+++ openlp/core/lib/serviceitem.py 2012-11-07 21:16:20 +0000
@@ -452,14 +452,27 @@
except IndexError:
return u''
- def get_frame_path(self, row=0):
+ def get_frame_path(self, row=0, frame=None):
"""
Returns the path of the raw frame
"""
- try:
- return self._raw_frames[row][u'path']
- except IndexError:
- return u''
+ if not frame:
+ try:
+ frame = self._raw_frames[row]
+ except IndexError:
+ return u''
+ if self.is_image():
+ path_from = frame[u'path']
+ else:
+ path_from = os.path.join(frame[u'path'], frame[u'title'])
+ return path_from
+
+ def remove_frame(self, frame):
+ """
+ Remove the soecified frame from the item
+ """
+ if frame in self._raw_frames:
+ self._raw_frames.remove(frame)
def get_media_time(self):
"""
@@ -496,3 +509,17 @@
self._new_item()
self.render()
+ def remove_invalid_frames(self, invalid_paths=None):
+ """
+ Remove invalid frames, such as ones where the file no longer exists.
+ """
+ if self.uses_file():
+ for frame in self.get_frames():
+ if self.get_frame_path(frame=frame) in invalid_paths:
+ self.remove_frame(frame)
+
+ def validate(self):
+ """
+ Validates this service item
+ """
+ return bool(self._raw_frames)
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2012-10-21 14:07:57 +0000
+++ openlp/core/ui/servicemanager.py 2012-11-07 21:16:20 +0000
@@ -484,59 +484,62 @@
path)
service = []
write_list = []
+ missing_list = []
audio_files = []
total_size = 0
Receiver.send_message(u'cursor_busy')
# Number of items + 1 to zip it
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
+ # Get list of missing files, and list of files to write
for item in self.serviceItems:
- self.mainwindow.incrementProgressBar()
- service_item = item[u'service_item'].get_service_repr()
- # Get all the audio files, and ready them for embedding in the
- # service file.
- if service_item[u'header'][u'background_audio']:
- for i, filename in \
- enumerate(service_item[u'header'][u'background_audio']):
- new_file = os.path.join(u'audio',
- item[u'service_item']._uuid, filename)
- audio_files.append((filename, new_file))
- service_item[u'header'][u'background_audio'][i] = new_file
- # Add the service item to the service.
- service.append({u'serviceitem': service_item})
if not item[u'service_item'].uses_file():
continue
- skipMissing = False
for frame in item[u'service_item'].get_frames():
- if item[u'service_item'].is_image():
- path_from = frame[u'path']
- else:
- path_from = os.path.join(frame[u'path'], frame[u'title'])
- # Only write a file once
- if path_from in write_list:
+ path_from = item[u'service_item'].get_frame_path(frame=frame)
+ if path_from in write_list or path_from in missing_list:
continue
if not os.path.exists(path_from):
- if not skipMissing:
- Receiver.send_message(u'cursor_normal')
- title = unicode(translate('OpenLP.ServiceManager',
- 'Service File Missing'))
- message = unicode(translate('OpenLP.ServiceManager',
- 'File missing from service\n\n %s \n\n'
- 'Continue saving?')) % path_from
- answer = QtGui.QMessageBox.critical(self, title,
- message,
- QtGui.QMessageBox.StandardButtons(
- QtGui.QMessageBox.Yes | QtGui.QMessageBox.No |
- QtGui.QMessageBox.YesToAll))
- if answer == QtGui.QMessageBox.No:
- self.mainwindow.finishedProgressBar()
- return False
- if answer == QtGui.QMessageBox.YesToAll:
- skipMissing = True
- Receiver.send_message(u'cursor_busy')
+ missing_list.append(path_from)
else:
- file_size = os.path.getsize(path_from)
write_list.append(path_from)
- total_size += file_size
+ if missing_list:
+ Receiver.send_message(u'cursor_normal')
+ title = unicode(translate('OpenLP.ServiceManager',
+ 'Service File(s) Missing'))
+ message = unicode(translate('OpenLP.ServiceManager',
+ 'The following file(s) in the service are missing:\n\t%s\n\n'
+ 'These files will be removed if you continue to save.')
+ ) % "\n\t".join(missing_list)
+ answer = QtGui.QMessageBox.critical(self, title,
+ message,
+ QtGui.QMessageBox.StandardButtons(
+ QtGui.QMessageBox.Ok | QtGui.QMessageBox.Cancel))
+ if answer == QtGui.QMessageBox.Cancel:
+ self.mainwindow.finishedProgressBar()
+ return False
+ Receiver.send_message(u'cursor_busy')
+ # Check if item contains a missing file.
+ for item in list(self.serviceItems):
+ self.mainwindow.incrementProgressBar()
+ item[u'service_item'].remove_invalid_frames(missing_list)
+ if not item[u'service_item'].validate():
+ self.serviceItems.remove(item)
+ else:
+ service_item = item[u'service_item'].get_service_repr()
+ if service_item[u'header'][u'background_audio']:
+ for i, filename in enumerate(
+ service_item[u'header'][u'background_audio']):
+ new_file = os.path.join(u'audio',
+ item[u'service_item']._uuid, filename)
+ audio_files.append((filename, new_file))
+ service_item[u'header'][u'background_audio'][i] = \
+ new_file
+ # Add the service item to the service.
+ service.append({u'serviceitem': service_item})
+ self.repaintServiceList(-1, -1)
+ for file in write_list:
+ file_size = os.path.getsize(file)
+ total_size += file_size
log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' %
total_size)
service_content = cPickle.dumps(service)
=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py 2012-10-21 14:07:57 +0000
+++ openlp/core/ui/slidecontroller.py 2012-11-07 21:16:20 +0000
@@ -1351,7 +1351,7 @@
Respond to the arrival of a media service item
"""
log.debug(u'SlideController onMediaStart')
- file = os.path.join(item.get_frame_path(), item.get_frame_title())
+ file = item.get_frame_path()
self.mediaController.video(self, file, False, False, self.hideMode())
if not self.isLive or self.mediaController.withLivePreview:
self.previewDisplay.show()
=== modified file 'openlp/plugins/presentations/lib/messagelistener.py'
--- openlp/plugins/presentations/lib/messagelistener.py 2012-10-21 14:07:57 +0000
+++ openlp/plugins/presentations/lib/messagelistener.py 2012-11-07 21:16:20 +0000
@@ -330,7 +330,7 @@
item = message[0]
log.debug(u'Startup called with message %s' % message)
hide_mode = message[2]
- file = os.path.join(item.get_frame_path(), item.get_frame_title())
+ file = item.get_frame_path()
self.handler = item.title
if self.handler == self.mediaitem.Automatic:
self.handler = self.mediaitem.findControllerByType(file)
Follow ups