openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #20877
[Merge] lp:~tomasgroth/openlp/json-service-format-20 into lp:openlp/2.0
Tomas Groth has proposed merging lp:~tomasgroth/openlp/json-service-format-20 into lp:openlp/2.0.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/json-service-format-20/+merge/172240
Change service format from pickle based to json based. Still support for loading pickle based services.
--
https://code.launchpad.net/~tomasgroth/openlp/json-service-format-20/+merge/172240
Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/json-service-format-20 into lp:openlp/2.0.
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2012-12-30 19:41:24 +0000
+++ openlp/core/ui/servicemanager.py 2013-06-30 12:31:33 +0000
@@ -32,6 +32,7 @@
import os
import shutil
import zipfile
+import json
from tempfile import mkstemp
from datetime import datetime, timedelta
@@ -477,7 +478,7 @@
path_file_name = unicode(self.fileName())
path, file_name = os.path.split(path_file_name)
basename = os.path.splitext(file_name)[0]
- service_file_name = '%s.osd' % basename
+ service_file_name = '%s.osj' % basename
log.debug(u'ServiceManager.saveFile - %s', path_file_name)
SettingsManager.set_last_dir(
self.mainwindow.serviceManagerSettingsSection,
@@ -542,7 +543,7 @@
total_size += file_size
log.debug(u'ServiceManager.saveFile - ZIP contents size is %i bytes' %
total_size)
- service_content = cPickle.dumps(service)
+ service_content = json.dumps(service)
# Usual Zip file cannot exceed 2GiB, file with Zip64 cannot be
# extracted using unzip in UNIX.
allow_zip_64 = (total_size > 2147483648 + len(service_content))
@@ -672,12 +673,15 @@
log.debug(u'Extract file: %s', osfile)
zipinfo.filename = osfile
zip.extract(zipinfo, self.servicePath)
- if osfile.endswith(u'osd'):
+ if osfile.endswith(u'osd') or osfile.endswith(u'osj'):
p_file = os.path.join(self.servicePath, osfile)
if 'p_file' in locals():
Receiver.send_message(u'cursor_busy')
fileTo = open(p_file, u'r')
- items = cPickle.load(fileTo)
+ if p_file.endswith(u'osj'):
+ items = json.load(fileTo)
+ else:
+ items = cPickle.load(fileTo)
fileTo.close()
self.newFile()
self.mainwindow.displayProgressBar(len(items))
Follow ups