Merge lp:~meths/openlp/trivialfixes into lp:openlp

Proposed by Jon Tibble
Status: Merged
Merged at revision: not available
Proposed branch: lp:~meths/openlp/trivialfixes
Merge into: lp:openlp
Diff against target: None lines
To merge this branch: bzr merge lp:~meths/openlp/trivialfixes
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+12121@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Jon Tibble (meths) wrote :

Fix service loading on Windows

Revision history for this message
Tim Bentley (trb143) wrote :

Nice One

review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve
lp:~meths/openlp/trivialfixes updated
555. By Jon Tibble

Fix service loading on Windows

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'openlp/core/ui/servicemanager.py'
--- openlp/core/ui/servicemanager.py 2009-09-18 18:20:58 +0000
+++ openlp/core/ui/servicemanager.py 2009-09-19 19:37:01 +0000
@@ -24,6 +24,7 @@
2424
25import os25import os
26import sys26import sys
27import string
27import logging28import logging
28import cPickle29import cPickle
29import zipfile30import zipfile
@@ -416,7 +417,7 @@
416 directory and will only be used for this service.417 directory and will only be used for this service.
417 """418 """
418 filename = QtGui.QFileDialog.getOpenFileName(self,419 filename = QtGui.QFileDialog.getOpenFileName(self,
419 u'Open Order of Service',self.config.get_last_dir(),420 u'Open Order of Service', self.config.get_last_dir(),
420 u'Services (*.oos)')421 u'Services (*.oos)')
421 filename = unicode(filename)422 filename = unicode(filename)
422 name = filename.split(os.path.sep)423 name = filename.split(os.path.sep)
@@ -426,14 +427,17 @@
426 zip = zipfile.ZipFile(unicode(filename))427 zip = zipfile.ZipFile(unicode(filename))
427 filexml = None428 filexml = None
428 themename = None429 themename = None
429
430 for file in zip.namelist():430 for file in zip.namelist():
431 names = file.split(os.path.sep)431 if os.name == u'nt':
432 winfile = string.replace(file, '/', os.path.sep)
433 names = winfile.split(os.path.sep)
434 else:
435 names = file.split(os.path.sep)
432 file_to = os.path.join(self.servicePath,436 file_to = os.path.join(self.servicePath,
433 names[len(names) - 1])437 names[len(names) - 1])
434 file_data = zip.read(file)438 f = open(file_to, u'wb')
435 f = open(file_to, u'w')439 f.write(zip.read(file))
436 f.write(file_data)440 f.flush()
437 f.close()441 f.close()
438 if file_to.endswith(u'ood'):442 if file_to.endswith(u'ood'):
439 p_file = file_to443 p_file = file_to
@@ -449,11 +453,9 @@
449 try:453 try:
450 os.remove(p_file)454 os.remove(p_file)
451 except:455 except:
452 #if not present do not worry456 log.exception(u'Failed to remove ood file')
453 pass
454 except:457 except:
455 log.exception(u'Problem loading a service file')458 log.exception(u'Problem loading a service file')
456 pass
457 self.isNew = False459 self.isNew = False
458 self.serviceName = name[len(name) - 1]460 self.serviceName = name[len(name) - 1]
459 self.parent.OosChanged(True, self.serviceName)461 self.parent.OosChanged(True, self.serviceName)