forked from openlp/openlp
modified servicemanager to check for missing files during service save
This commit is contained in:
parent
187bb647c0
commit
7f440527f8
@ -465,10 +465,13 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
service = []
|
service = []
|
||||||
write_list = []
|
write_list = []
|
||||||
total_size = 0
|
total_size = 0
|
||||||
|
abort_save = False
|
||||||
Receiver.send_message(u'cursor_busy')
|
Receiver.send_message(u'cursor_busy')
|
||||||
# Number of items + 1 to zip it
|
# Number of items + 1 to zip it
|
||||||
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
|
self.mainwindow.displayProgressBar(len(self.serviceItems) + 1)
|
||||||
for item in self.serviceItems:
|
for item in self.serviceItems:
|
||||||
|
if abort_save:
|
||||||
|
continue
|
||||||
self.mainwindow.incrementProgressBar()
|
self.mainwindow.incrementProgressBar()
|
||||||
service.append({u'serviceitem':
|
service.append({u'serviceitem':
|
||||||
item[u'service_item'].get_service_repr()})
|
item[u'service_item'].get_service_repr()})
|
||||||
@ -482,25 +485,45 @@ class ServiceManager(QtGui.QWidget):
|
|||||||
# Only write a file once
|
# Only write a file once
|
||||||
if path_from in write_list:
|
if path_from in write_list:
|
||||||
continue
|
continue
|
||||||
file_size = os.path.getsize(path_from)
|
if not os.path.isfile(path_from):
|
||||||
size_limit = 52428800 # 50MiB
|
Receiver.send_message(u'cursor_normal')
|
||||||
#if file_size > size_limit:
|
title = unicode(translate('OpenLP.ServiceManager',
|
||||||
# # File exeeds size_limit bytes, ask user
|
'Service File Missing'))
|
||||||
# message = unicode(translate('OpenLP.ServiceManager',
|
message = unicode(translate('OpenLP.ServiceManager',
|
||||||
# 'Do you want to include \n%.1f MB file "%s"\n'
|
'File missing from service\n\n %s \n\n'
|
||||||
# 'into the service file?\nThis may take some time.\n\n'
|
'Continue saving?' % path_from ))
|
||||||
# 'Please note that you need to\ntake care of that file'
|
ans = QtGui.QMessageBox.critical(self, title, message,
|
||||||
# ' yourself,\nif you leave it out.')) % \
|
QtGui.QMessageBox.StandardButtons(
|
||||||
# (file_size/1048576, os.path.split(path_from)[1])
|
QtGui.QMessageBox.Yes | QtGui.QMessageBox.No))
|
||||||
# ans = QtGui.QMessageBox.question(self.mainwindow,
|
if ans == QtGui.QMessageBox.No:
|
||||||
# translate('OpenLP.ServiceManager', 'Including Large '
|
abort_save = True
|
||||||
# 'File'), message, QtGui.QMessageBox.StandardButtons(
|
continue
|
||||||
# QtGui.QMessageBox.Ok|QtGui.QMessageBox.Cancel),
|
Receiver.send_message(u'cursor_busy')
|
||||||
# QtGui.QMessageBox.Ok)
|
else:
|
||||||
# if ans == QtGui.QMessageBox.Cancel:
|
file_size = os.path.getsize(path_from)
|
||||||
# continue
|
size_limit = 52428800 # 50MiB
|
||||||
write_list.append(path_from)
|
#if file_size > size_limit:
|
||||||
total_size += file_size
|
# # File exeeds size_limit bytes, ask user
|
||||||
|
# message = unicode(translate('OpenLP.ServiceManager',
|
||||||
|
# 'Do you want to include \n%.1f MB file "%s"\n'
|
||||||
|
# 'into the service file?\nThis may take some time.\n\n'
|
||||||
|
# 'Please note that you need to\ntake care of that file'
|
||||||
|
# ' yourself,\nif you leave it out.')) % \
|
||||||
|
# (file_size/1048576, os.path.split(path_from)[1])
|
||||||
|
# ans = QtGui.QMessageBox.question(self.mainwindow,
|
||||||
|
# translate('OpenLP.ServiceManager', 'Including Large '
|
||||||
|
# 'File'), message, QtGui.QMessageBox.StandardButtons(
|
||||||
|
# QtGui.QMessageBox.Ok|QtGui.QMessageBox.Cancel),
|
||||||
|
# QtGui.QMessageBox.Ok)
|
||||||
|
# if ans == QtGui.QMessageBox.Cancel:
|
||||||
|
# continue
|
||||||
|
write_list.append(path_from)
|
||||||
|
total_size += file_size
|
||||||
|
if abort_save:
|
||||||
|
self._fileName = u''
|
||||||
|
self.mainwindow.finishedProgressBar()
|
||||||
|
Receiver.send_message(u'cursor_normal')
|
||||||
|
return False
|
||||||
log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' %
|
log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' %
|
||||||
total_size)
|
total_size)
|
||||||
service_content = cPickle.dumps(service)
|
service_content = cPickle.dumps(service)
|
||||||
|
Loading…
Reference in New Issue
Block a user