diff --git a/cnvdb.py b/cnvdb.py deleted file mode 100755 index 1e1acdd32..000000000 --- a/cnvdb.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4 - -############################################################################### -# OpenLP - Open Source Lyrics Projection # -# --------------------------------------------------------------------------- # -# Copyright (c) 2008-2009 Raoul Snyman # -# Portions copyright (c) 2008-2009 Martin Thompson, Tim Bentley, Carsten # -# Tinggaard, Jon Tibble, Jonathan Corwin, Maikel Stuivenberg, Scott Guerrieri # -# --------------------------------------------------------------------------- # -# This program is free software; you can redistribute it and/or modify it # -# under the terms of the GNU General Public License as published by the Free # -# Software Foundation; version 2 of the License. # -# # -# This program is distributed in the hope that it will be useful, but WITHOUT # -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for # -# more details. # -# # -# You should have received a copy of the GNU General Public License along # -# with this program; if not, write to the Free Software Foundation, Inc., 59 # -# Temple Place, Suite 330, Boston, MA 02111-1307 USA # -############################################################################### - -import codecs -import sys - -def convert_file(inname, outname): - """ - Convert a file from another encoding into UTF-8. - - ``inname`` - The name of the file to be opened and converted. - - ``outname`` - The output file name. - """ - infile = codecs.open(inname, 'r', encoding='CP1252') - writefile = codecs.open(outname, 'w', encoding='utf-8') - for line in infile: - #replace the quotes with quotes - #TODO fix double quotes - #line = line.replace(u'\'\'', u'@') - writefile.write(line) - infile.close() - writefile.close() - -if __name__ == '__main__': - """ - Run the conversion script. - """ - if len(sys.argv) < 2: - print 'No action specified.' - sys.exit() - print 'Uncode conversion:' - print 'Input file = ', sys.argv[1] - print 'Output file = ', sys.argv[2] - print 'Converting...' - convert_file(sys.argv[1], sys.argv[2]) - print 'Done.' diff --git a/openlp-1to2-converter.py b/openlp-1to2-converter.py index 66660af70..dd1d601dd 100644 --- a/openlp-1to2-converter.py +++ b/openlp-1to2-converter.py @@ -174,8 +174,8 @@ def import_songs(): search_title = clean_string(clean_title) search_lyrics = clean_string(clean_lyrics) sql_insert = u'INSERT INTO songs '\ - '(id, title, lyrics, verse_order, copyright, search_title, search_lyrics) '\ - 'VALUES (NULL, ?, ?, ?, ?, ?, ?)' + '(id, song_book_id, title, lyrics, verse_order, copyright, search_title, search_lyrics) '\ + 'VALUES (NULL, 0, ?, ?, ?, ?, ?, ?)' sql_params = (clean_title, xml_lyrics, verse_order, clean_copyright, clean_title, clean_lyrics) if debug: print '...', display_sql(sql_insert, (sql_params[0], u'%s...' % clean_lyrics[:7], sql_params[2], sql_params[3], sql_params[4], u'%s...' % search_lyrics[:7])) diff --git a/openlp/core/lib/renderer.py b/openlp/core/lib/renderer.py index 8bba8e912..572d96ade 100644 --- a/openlp/core/lib/renderer.py +++ b/openlp/core/lib/renderer.py @@ -561,8 +561,6 @@ class Renderer(object): ``image2`` Defaults to *None*. Another image to save to disk. """ - im = image.toImage() - im.save(u'renderer.png', u'png') + image.save(u'renderer.png', u'png') if image2 is not None: - im = image2.toImage() - im.save(u'renderer2.png', u'png') + image2.save(u'renderer2.png', u'png') diff --git a/openlp/core/lib/toolbar.py b/openlp/core/lib/toolbar.py index 81ee3e667..b0473b767 100644 --- a/openlp/core/lib/toolbar.py +++ b/openlp/core/lib/toolbar.py @@ -136,4 +136,4 @@ class OpenLPToolbar(QtGui.QToolBar): pushButton.setCheckable(True) pushButton.setFlat(True) self.addWidget(pushButton) - return pushButton \ No newline at end of file + return pushButton diff --git a/openlp/core/ui/generaltab.py b/openlp/core/ui/generaltab.py index 46941b6fa..0c3af4c5d 100644 --- a/openlp/core/ui/generaltab.py +++ b/openlp/core/ui/generaltab.py @@ -173,7 +173,7 @@ class GeneralTab(SettingsTab): self.MonitorComboBox.addItem(screen_name) # Get the configs self.MonitorNumber = int(self.config.get_config(u'Monitor', u'0')) - self.Warning = str_to_bool(self.config.get_config(u'Warning', u'False')) + self.Warning = str_to_bool(self.config.get_config(u'Blank Warning', u'False')) self.AutoOpen = str_to_bool(self.config.get_config(u'Auto Open', u'False')) self.ShowSplash = str_to_bool(self.config.get_config(u'show splash', u'True')) self.CCLNumber = unicode(self.config.get_config(u'CCL Number', u'XXX')) @@ -190,7 +190,7 @@ class GeneralTab(SettingsTab): def save(self): self.config.set_config(u'Monitor', self.MonitorNumber) - self.config.set_config(u'Warning', self.Warning) + self.config.set_config(u'Blank Warning', self.Warning) self.config.set_config(u'Auto Open', self.AutoOpen) self.config.set_config(u'show splash', self.ShowSplash) self.config.set_config(u'CCL Number', self.CCLNumber) diff --git a/openlp/core/ui/maindisplay.py b/openlp/core/ui/maindisplay.py index e98d1eb96..6f3bf910d 100644 --- a/openlp/core/ui/maindisplay.py +++ b/openlp/core/ui/maindisplay.py @@ -182,6 +182,7 @@ class MainDisplay(DisplayLabel): self.displayBlank = False if self.frame is not None: self.frameView(self.frame) + self.parent.generalConfig.set_config(u'Screen Blank',self.displayBlank) def displayAlert(self, text=u''): """ diff --git a/openlp/core/ui/mainwindow.py b/openlp/core/ui/mainwindow.py index cac0b8e0a..601cab59a 100644 --- a/openlp/core/ui/mainwindow.py +++ b/openlp/core/ui/mainwindow.py @@ -32,7 +32,7 @@ from openlp.core.ui import AboutForm, SettingsForm, AlertForm, \ PluginForm, MediaDockManager from openlp.core.lib import translate, RenderManager, PluginConfig, \ OpenLPDockWidget, SettingsManager, PluginManager, Receiver, \ - buildIcon + buildIcon, str_to_bool from openlp.core.utils import check_latest_version media_manager_style = """ @@ -438,7 +438,7 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.mainDisplay = MainDisplay(self, screens) self.alertForm = AlertForm(self) self.aboutForm = AboutForm(self) - self.settingsForm = SettingsForm(self.screenList, self) + self.settingsForm = SettingsForm(self.screenList, self, self) # Set up the path with plugins pluginpath = os.path.split(os.path.abspath(__file__))[0] pluginpath = os.path.abspath( @@ -540,7 +540,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): self.ThemeManagerContents.loadThemes() log.info(u'Load data from Settings') self.settingsForm.postSetUp() - self.versionCheck() def versionCheck(self): applicationVersion = self.generalConfig.get_config(u'Application version', u'1.9.0-595') @@ -569,7 +568,6 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): monitor_exists = True if not monitor_exists: screen_number = 0 - return screen_number def show(self): @@ -580,6 +578,17 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow): screen_number = self.getMonitorNumber() self.mainDisplay.setup(screen_number) self.setFocus() + self.versionCheck() + if str_to_bool(self.generalConfig.get_config(u'Auto Open', False)): + self.ServiceManagerContents.onLoadService(True) + if str_to_bool(self.generalConfig.get_config(u'Screen Blank', False)) \ + and str_to_bool(self.generalConfig.get_config(u'Blank Warning', False)): + QtGui.QMessageBox.question(None, + translate(u'mainWindow', u'OpenLP Main Display Blanked'), + translate(u'mainWindow', u'The Main Display has been blanked out'), + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok), + QtGui.QMessageBox.Ok) + self.LiveController.blackPushButton.setChecked(True) def onHelpAboutItemClicked(self): """ diff --git a/openlp/core/ui/mediadockmanager.py b/openlp/core/ui/mediadockmanager.py index e7e7d53a1..4b1d64178 100644 --- a/openlp/core/ui/mediadockmanager.py +++ b/openlp/core/ui/mediadockmanager.py @@ -24,7 +24,7 @@ import logging -log = logging.getLogger(u'media_dockManager') +log = logging.getLogger(u'MediaDockManager') class MediaDockManager(object): diff --git a/openlp/core/ui/servicemanager.py b/openlp/core/ui/servicemanager.py index 29a0acf06..2b5838b3f 100644 --- a/openlp/core/ui/servicemanager.py +++ b/openlp/core/ui/servicemanager.py @@ -420,16 +420,19 @@ class ServiceManager(QtGui.QWidget): def onQuickSaveService(self): self.onSaveService(True) - def onLoadService(self): + def onLoadService(self, lastService = False): """ Load an existing service from disk and rebuild the serviceitems. All files retrieved from the zip file are placed in a temporary directory and will only be used for this service. """ - filename = QtGui.QFileDialog.getOpenFileName(self, - translate(u'ThemeManager', u'Open Service'), - self.config.get_last_dir(), - u'Services (*.osz)') + if lastService: + filename = self.config.get_last_dir() + else: + filename = QtGui.QFileDialog.getOpenFileName(self, + translate(u'ThemeManager', u'Open Service'), + self.config.get_last_dir(), + u'Services (*.osz)') filename = unicode(filename) name = filename.split(os.path.sep) if filename != u'': diff --git a/openlp/core/ui/settingsform.py b/openlp/core/ui/settingsform.py index b00e622cf..6d17009af 100644 --- a/openlp/core/ui/settingsform.py +++ b/openlp/core/ui/settingsform.py @@ -35,7 +35,7 @@ log = logging.getLogger(u'SettingsForm') class SettingsForm(QtGui.QDialog, Ui_SettingsDialog): def __init__(self, screen_list, mainWindow, parent=None): - QtGui.QDialog.__init__(self, None) + QtGui.QDialog.__init__(self, parent) self.setupUi(self) # General tab self.GeneralTab = GeneralTab(screen_list) diff --git a/openlp/core/ui/thememanager.py b/openlp/core/ui/thememanager.py index 824b53880..50e433534 100644 --- a/openlp/core/ui/thememanager.py +++ b/openlp/core/ui/thememanager.py @@ -292,8 +292,8 @@ class ThemeManager(QtGui.QWidget): xml = newtheme.extract_xml() theme = ThemeXML() theme.parse(xml) - theme.extend_image_filename(self.path) self.cleanTheme(theme) + theme.extend_image_filename(self.path) return theme def checkThemesExists(self, dir): diff --git a/openlp/migration/migratesongs.py b/openlp/migration/migratesongs.py index 51695b9cb..8fced1650 100644 --- a/openlp/migration/migratesongs.py +++ b/openlp/migration/migratesongs.py @@ -170,12 +170,12 @@ class MigrateSongs(): else: author = self.session.query(Author).get(bb[0]) song.authors.append(author) - try: - self.session.add(song) - self.session.commit() - except: - self.session.rollback() - print u'Errow thrown = ', sys.exc_info()[1] + try: + self.session.add(song) + self.session.commit() + except: + self.session.rollback() + print u'Error thrown = ', sys.exc_info()[1] def _v1_9_0_cleanup(self, database): self.display.sub_output(u'Update Internal Data ' + database) diff --git a/openlp/plugins/audit/forms/auditdetailform.py b/openlp/plugins/audit/forms/auditdetailform.py index 74e28f394..d93c07527 100644 --- a/openlp/plugins/audit/forms/auditdetailform.py +++ b/openlp/plugins/audit/forms/auditdetailform.py @@ -25,8 +25,6 @@ from PyQt4 import QtCore, QtGui from auditdetaildialog import Ui_AuditDetailDialog -from openlp.core.lib import translate -#from openlp.plugins.audit.lib.models import CustomSlide class AuditDetailForm(QtGui.QDialog, Ui_AuditDetailDialog): """ diff --git a/openlpcnv.pyw b/openlpcnv.pyw index 98e391f81..76a7139dc 100755 --- a/openlpcnv.pyw +++ b/openlpcnv.pyw @@ -26,17 +26,31 @@ import os import logging import time +import subprocess +import codecs +import sys +from datetime import date +if os.name == u'nt': + import win32api + import win32con + from win32com.client import Dispatch from openlp.migration.display import * from openlp.migration.migratefiles import * from openlp.migration.migratebibles import * from openlp.migration.migratesongs import * +############################################################################### +# For Windows, requires SQLite ODBC Driver to be installed +# (uses sqlite.exe and sqlite3.exe) +# http://www.ch-werner.de/sqliteodbc/ +############################################################################### + logging.basicConfig(level=logging.DEBUG, - format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', - datefmt='%m-%d %H:%M', - filename='openlp-migration.log', - filemode='w') + format=u'%(asctime)s %(name)-12s %(levelname)-8s %(message)s', + datefmt=u'%m-%d %H:%M', + filename=u'openlp-migration.log', + filemode=u'w') class Migration(object): """ @@ -62,15 +76,75 @@ class Migration(object): """ Move the log file to a new location. """ - fname = 'openlp-migration.log' + fname = u'openlp-migration.log' c = os.path.splitext(fname) b = (c[0]+'-'+ unicode(self.stime) + c[1]) - self.display.output(u'Logfile " +b + " generated') + self.display.output(u'Logfile ' + b + u' generated') self.display.output(u'Migration Utility Finished ') os.rename(fname, b) + def convert_file(self, inname, outname): + """ + Convert a file from another encoding into UTF-8. -if __name__ == '__main__': + ``inname`` + The name of the file to be opened and converted. + + ``outname`` + The output file name. + """ + infile = codecs.open(inname, u'r', encoding=u'CP1252') + writefile = codecs.open(outname, u'w', encoding=u'utf-8') + for line in infile: + writefile.write(line) + infile.close() + writefile.close() + + def convert_sqlite2_to_3(self, olddb, newdb): + if os.name == u'nt': + # we can't make this a raw unicode string as the \U within it causes much confusion + hKey = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, u'SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\SQLite ODBC Driver') + value, type = win32api.RegQueryValueEx (hKey, u'UninstallString') + sqlitepath, temp = os.path.split(value) + sqliteexe = os.path.join(sqlitepath, u'sqlite.exe') + else: + sqliteexe = u'sqlite' + cmd = u'%s "%s" .dump' % (sqliteexe, olddb) + if os.name == u'nt': + subprocess.call(cmd, stdout=open(u'sqlite.dmp', u'w')) + else: + subprocess.call(cmd, stdout=open(u'sqlite.dmp', u'w'), shell=True) + self.convert_file(u'sqlite.dmp', u'sqlite3.dmp') + if os.name == u'nt': + sqlite3exe = os.path.join(sqlitepath, u'sqlite3.exe') + else: + sqlite3exe = u'sqlite3' + if os.path.isfile(newdb): + saveddb = newdb + self.stime + os.rename(newdb, saveddb) + cmd = '%s "%s"' % (sqlite3exe, newdb) + if os.name == u'nt': + subprocess.call(cmd, stdin=open(u'sqlite3.dmp', u'r')) + else: + subprocess.call(cmd, stdin=open(u'sqlite3.dmp', u'r'), shell=True) + os.remove(u'sqlite.dmp') + os.remove(u'sqlite3.dmp') + +if __name__ == u'__main__': mig = Migration() + config = PluginConfig(u'Songs') + newpath = config.get_data_path() + if os.name == u'nt': + if not os.path.isdir(newpath): + os.makedirs(newpath) + ALL_USERS_APPLICATION_DATA = 35 + shell = Dispatch(u'Shell.Application') + folder = shell.Namespace(ALL_USERS_APPLICATION_DATA) + folderitem = folder.Self + olddb = os.path.join(folderitem.path, u'openlp.org', u'Data', u'songs.olp') + else: + olddb = os.path.join(newpath, u'songs.olp') + newdb = os.path.join(newpath, u'songs.sqlite') + mig.convert_sqlite2_to_3(olddb, newdb) mig.process() #mig.move_log_file() diff --git a/songcnv.sh b/songcnv.sh deleted file mode 100755 index b7ef2a173..000000000 --- a/songcnv.sh +++ /dev/null @@ -1,5 +0,0 @@ -/usr/bin/sqlite ~/.local/share/openlp/songs/songs.olp .dump > ~/.local/share/openlp/songs/songs.dmp -./cnvdb.py ~/.local/share/openlp/songs/songs.dmp ~/.local/share/openlp/songs/songs.dmp2 -rm ~/.local/share/openlp/songs/songs.sqlite -sqlite3 ~/.local/share/openlp/songs/songs.sqlite < ~/.local/share/openlp/songs/songs.dmp2 -./openlpcnv.pyw