forked from openlp/openlp
use filesystem char encoding for file operations
This commit is contained in:
parent
2dac357fa7
commit
69c6e0ef02
@ -36,7 +36,7 @@ from openlp.core.theme import Theme
|
||||
from openlp.core.lib import OpenLPToolbar, contextMenuAction, \
|
||||
ThemeXML, str_to_bool, get_text_file_string, build_icon, Receiver, \
|
||||
contextMenuSeparator, SettingsManager, translate
|
||||
from openlp.core.utils import AppLocation
|
||||
from openlp.core.utils import AppLocation, get_filesystem_encoding
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -211,7 +211,9 @@ class ThemeManager(QtGui.QWidget):
|
||||
try:
|
||||
os.remove(os.path.join(self.path, th))
|
||||
os.remove(os.path.join(self.thumbPath, th))
|
||||
shutil.rmtree(os.path.join(self.path, theme))
|
||||
encoding = get_filesystem_encoding()
|
||||
shutil.rmtree(
|
||||
os.path.join(self.path, theme).encode(encoding))
|
||||
except OSError:
|
||||
#if not present do not worry
|
||||
pass
|
||||
@ -495,7 +497,10 @@ class ThemeManager(QtGui.QWidget):
|
||||
outfile.close()
|
||||
if image_from and image_from != image_to:
|
||||
try:
|
||||
shutil.copyfile(image_from, image_to)
|
||||
encoding = get_filesystem_encoding()
|
||||
shutil.copyfile(
|
||||
unicode(image_from).encode(encoding),
|
||||
unicode(image_to).encode(encoding))
|
||||
except IOError:
|
||||
log.exception(u'Failed to save theme image')
|
||||
self.generateAndSaveImage(self.path, name, theme_xml)
|
||||
|
@ -163,7 +163,17 @@ def add_actions(target, actions):
|
||||
else:
|
||||
target.addAction(action)
|
||||
|
||||
def get_filesystem_encoding():
|
||||
"""
|
||||
Returns the name of the encoding used to convert Unicode filenames into
|
||||
system file names.
|
||||
"""
|
||||
encoding = sys.getfilesystemencoding()
|
||||
if encoding is None:
|
||||
encoding = sys.getdefaultencoding()
|
||||
return encoding
|
||||
|
||||
from languagemanager import LanguageManager
|
||||
|
||||
__all__ = [u'AppLocation', u'check_latest_version', u'add_actions',
|
||||
u'LanguageManager']
|
||||
u'get_filesystem_encoding', u'LanguageManager']
|
||||
|
@ -419,9 +419,7 @@ class ImportWizardForm(QtGui.QWizard, Ui_BibleImportWizard):
|
||||
# Import a bible from the web
|
||||
self.ImportProgressBar.setMaximum(1)
|
||||
download_location = self.field(u'web_location').toInt()[0]
|
||||
bible_version = self.BibleComboBox.currentText()
|
||||
if not isinstance(bible_version, unicode):
|
||||
bible_version = unicode(bible_version, u'utf8')
|
||||
bible_version = unicode(self.BibleComboBox.currentText())
|
||||
if download_location == WebDownload.Crosswalk:
|
||||
bible = \
|
||||
self.web_bible_list[WebDownload.Crosswalk][bible_version]
|
||||
|
Loading…
Reference in New Issue
Block a user