Migration tools settings conversion

This commit is contained in:
Jon Tibble 2010-04-28 04:16:49 +01:00
parent 507cd19739
commit 97d9ab93f6
4 changed files with 27 additions and 21 deletions

View File

@ -31,7 +31,8 @@ from sqlalchemy import *
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker, mapper
from openlp.core.lib import PluginConfig
from openlp.core.lib import SettingsManager
from openlp.core.utils import AppLocation
from openlp.plugins.bibles.lib.models import *
class BaseModel(object):
@ -111,9 +112,8 @@ def init_models(url):
class MigrateBibles():
def __init__(self, display):
self.display = display
self.config = PluginConfig(u'Bibles')
self.data_path = self.config.get_data_path()
self.database_files = self.config.get_files(u'sqlite')
self.data_path = AppLocation.get_section_data_path(u'bibles')
self.database_files = SettingsManager.get_files(u'bibles', u'.sqlite')
print self.database_files
def progress(self, text):

View File

@ -23,7 +23,7 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
from openlp.core.utils import ConfigHelper
from openlp.core.utils import AppLocation
class MigrateFiles():
def __init__(self, display):
@ -36,14 +36,19 @@ class MigrateFiles():
def _initial_setup(self):
self.display.output(u'Initial Setup started')
ConfigHelper.get_data_path()
data_path = AppLocation.get_data_path()
print data_path
self.display.sub_output(u'Config created')
ConfigHelper.get_config(u'bible', u'data path')
bibles_path = AppLocation.get_section_data_path(u'bibles')
print bibles_path
self.display.sub_output(u'Config created')
ConfigHelper.get_config(u'videos', u'data path')
self.display.sub_output(u'videos created')
ConfigHelper.get_config(u'images', u'data path')
# Media doesn't use a directory like the other plugins.
#media_path = AppLocation.get_section_data_path(u'media')
#self.display.sub_output(u'videos created')
images_path = AppLocation.get_section_data_path(u'images')
print images_path
self.display.sub_output(u'images created')
ConfigHelper.get_config(u'presentations', u'data path')
presentations_path = AppLocation.get_section_data_path(u'presentations')
print presentations_path
self.display.sub_output(u'presentations created')
self.display.output(u'Initial Setup finished')

View File

@ -31,7 +31,8 @@ from sqlalchemy import *
from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker, mapper, relation
from openlp.core.lib import PluginConfig
from openlp.core.lib import SettingsManager
from openlp.core.utils import AppLocation
from openlp.plugins.songs.lib.models import metadata, songs_table, Song, \
Author, Topic, Book
from openlp.plugins.songs.lib.tables import *
@ -111,9 +112,8 @@ class TSongAuthor(BaseModel):
class MigrateSongs():
def __init__(self, display):
self.display = display
self.config = PluginConfig(u'Songs')
self.data_path = self.config.get_data_path()
self.database_files = self.config.get_files(u'sqlite')
self.data_path = AppLocation.get_section_data_path(u'songs')
self.database_files = SettingsManager.get_files(u'songs', u'.sqlite')
print self.database_files
def process(self):

View File

@ -35,6 +35,7 @@ if os.name == u'nt':
import win32con
from win32com.client import Dispatch
from openlp.core.utils import AppLocation
from openlp.migration.display import *
from openlp.migration.migratefiles import *
from openlp.migration.migratebibles import *
@ -103,8 +104,10 @@ class Migration(object):
def convert_sqlite2_to_3(self, olddb, newdb):
print u'Converting sqlite2 ' + olddb + ' to sqlite3 ' + 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')
# 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')
@ -133,10 +136,8 @@ class Migration(object):
if __name__ == u'__main__':
mig = Migration()
songconfig = PluginConfig(u'Songs')
newsongpath = songconfig.get_data_path()
bibleconfig = PluginConfig(u'Bibles')
newbiblepath = bibleconfig.get_data_path()
newsongpath = AppLocation.get_section_data_path(u'songs')
newbiblepath = AppLocation.get_section_data_path(u'bibles')
if os.name == u'nt':
if not os.path.isdir(newsongpath):
os.makedirs(newsongpath)