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
1=== modified file 'openlp/core/ui/servicemanager.py'
2--- openlp/core/ui/servicemanager.py 2009-09-18 18:20:58 +0000
3+++ openlp/core/ui/servicemanager.py 2009-09-19 19:37:01 +0000
4@@ -24,6 +24,7 @@
5
6 import os
7 import sys
8+import string
9 import logging
10 import cPickle
11 import zipfile
12@@ -416,7 +417,7 @@
13 directory and will only be used for this service.
14 """
15 filename = QtGui.QFileDialog.getOpenFileName(self,
16- u'Open Order of Service',self.config.get_last_dir(),
17+ u'Open Order of Service', self.config.get_last_dir(),
18 u'Services (*.oos)')
19 filename = unicode(filename)
20 name = filename.split(os.path.sep)
21@@ -426,14 +427,17 @@
22 zip = zipfile.ZipFile(unicode(filename))
23 filexml = None
24 themename = None
25-
26 for file in zip.namelist():
27- names = file.split(os.path.sep)
28+ if os.name == u'nt':
29+ winfile = string.replace(file, '/', os.path.sep)
30+ names = winfile.split(os.path.sep)
31+ else:
32+ names = file.split(os.path.sep)
33 file_to = os.path.join(self.servicePath,
34 names[len(names) - 1])
35- file_data = zip.read(file)
36- f = open(file_to, u'w')
37- f.write(file_data)
38+ f = open(file_to, u'wb')
39+ f.write(zip.read(file))
40+ f.flush()
41 f.close()
42 if file_to.endswith(u'ood'):
43 p_file = file_to
44@@ -449,11 +453,9 @@
45 try:
46 os.remove(p_file)
47 except:
48- #if not present do not worry
49- pass
50+ log.exception(u'Failed to remove ood file')
51 except:
52 log.exception(u'Problem loading a service file')
53- pass
54 self.isNew = False
55 self.serviceName = name[len(name) - 1]
56 self.parent.OosChanged(True, self.serviceName)